Hi Everyone,
I have written the code which gives the system time in a window. But I need also to have the Internet address and the port number of the client in the window. the TimeserverRF considers incoming DatagramPackets as a request for the current time, if the client wishes to receive the current time from TimeserverRF, it has only has to send a DatagramPacket to TimeserverRF.
I am not sure how to do this writing DatagramPackets .
I have the TimeClient class application. Timeclient should send the Internet address and the port on which it is running.
Do You have any ideas.
// the code for system time.
import javax.swing.*;
public class Window1 {
public static void main(String[] args) {
JFrame win = new JFrame("TimeSer ver running on port 9999");
JTextArea tA = new JTextArea(1, 30);
win.getContentP ane().add(tA);
win.pack();
win.setVisible( true);
String s1; // initialise variables
TimeData t1; // TimeData object initalise to t1 variable
t1 = new TimeData(System .currentTimeMil lis()); // start of loop body
s1 = t1.toTimeString (); // system time held sring s1
tA.append("Sent "); tA.append(s1); // Prints statement and time in Frame
}
}
I have written the code which gives the system time in a window. But I need also to have the Internet address and the port number of the client in the window. the TimeserverRF considers incoming DatagramPackets as a request for the current time, if the client wishes to receive the current time from TimeserverRF, it has only has to send a DatagramPacket to TimeserverRF.
I am not sure how to do this writing DatagramPackets .
I have the TimeClient class application. Timeclient should send the Internet address and the port on which it is running.
Do You have any ideas.
// the code for system time.
import javax.swing.*;
public class Window1 {
public static void main(String[] args) {
JFrame win = new JFrame("TimeSer ver running on port 9999");
JTextArea tA = new JTextArea(1, 30);
win.getContentP ane().add(tA);
win.pack();
win.setVisible( true);
String s1; // initialise variables
TimeData t1; // TimeData object initalise to t1 variable
t1 = new TimeData(System .currentTimeMil lis()); // start of loop body
s1 = t1.toTimeString (); // system time held sring s1
tA.append("Sent "); tA.append(s1); // Prints statement and time in Frame
}
}
Comment