Getting the time using UDP

I have the following class (source code from java core tips):
public class GetTime {
     final private static int DAYTIME_PORT = 13;
     public static void main(String args[]) throws
     IOException {
          if (args.length == 0) {
               System.err.println
               ("Please specify daytime host");
               System.exit(-1);
          String host = args[0];
          byte message[] = new byte[256];
          InetAddress address = InetAddress.getByName(host);
          System.out.println("Checking at: " + address);
          DatagramPacket packet =
               new DatagramPacket(message, message.length,
                         address, DAYTIME_PORT);
          DatagramSocket socket = new DatagramSocket();
          socket.send(packet);
          packet =
               new DatagramPacket(message, message.length);
          socket.receive(packet);
          String time = new String(packet.getData());
          System.out.println("The time at" + host + " is: " + time);
          socket.close();
I am running this code but it does not show me the time. The host is the 'localhost'. I read that upon a connection to port 13 a response with the data and time should be automatically sent. By me it just prompts this: "Checking at: localhost/127.0.0.1" and it remains like that while it's still running...
Can anyone tell me what it's wrong. I've tried instead of localhost to give a time server name and changed the port number but it still doesn't work.

Is the Server running and listening on port 13????

Similar Messages

  • HOW CAN I GET THE TIME IN EXCEL SHEET USING WRITE TO MEASUREMENT INSTRUCTION

    HI, I am using GET TIME IN SECONDS ,and after that i placed SECONDS TO DATE /TIME instruction ,and i had taken a write to measurement file instruction
    to get the time in excel sheet. Now i am not able to connect write to measurement source to seconds to date and time output . Is there any solution.
    I am attaching my VI file also.
    Attachments:
    TEST.vi ‏43 KB

    Hi
    Im using Labview 8.2. Currently it just shows the data without the time. Im not sure what to do. It works perfectly though. I just want the time to appear on my notepad along with my data
    holla
    Attachments:
    Testing1.txt ‏1 KB
    Untitled 231_LV80.vi ‏23 KB

  • All the time using password it's say "wrong password. It a get a new one on the ipad2 do a new one it's "wrong password" Help me please

    All the time using password it's say "wrong password. It a get a new one on the ipad2 do a new one it's "wrong password" Help me please

    Is this with your iTunes account password ? If so, and if you haven't already done so, then try logging out of your account by tapping on it in Settings > Store and then log back in and see if that fixes it.

  • How to get the Time Stamp if we use User Status

    Hi Gurus,
    We used User Status to control several Orders. Now we are required to get the "time stamp" when we change from one status to another, is that information available in the system?
    If not, how do we get the time when a user status is changed from one to another?
    please advice,

    Hi,
    To check such kind of changes you have to follow below path,
    Go to Status tab (Blue Ikon) --- >Extra -> Change Documents-> All- --- > Choose All Changes
    SAP note 390635 provide the possibility to write change records for process and production orders as modification.
    please refer this link also,
    [Link|https://www.sdn.sap.com/irj/sdn/profile?userid=3781605]
    Regards,
    R.Brahmankar

  • Trying to get the time of analysis for tables in SAP

    Hi all,
    I'm using the update statistics command on some tables in my database.
    The num_rows attribute in the user_tables is updated after that but the last_analyzed attribute is not updated correctly.
    Does anyone know how ? or maybe a different way to get the time the table was analyzed ?
    Thanks,
    lital

    Dear Lital,
    Can you please specify the Database system you are using and the version?
    Thanks
    N.P.C

  • Can i get the time capsule to automatically back up my file from my Mac Book Air but have certain files which are only stored on the time capsule and not the computer? Then can i access these files only on the time capsule without connecting it?

    Can i get the time capsule to automatically back up my file from my Mac Book Air but have certain files which are only stored on the time capsule and not the computer? Then can i access these files only on the time capsule without connecting it?

    igonneau wrote:
    Can i get the time capsule to automatically back up my file from my Mac Book Air but have certain files which are only stored on the time capsule and not the computer?
    You can, but how are you going to back up those other files?  When (not if) your Time Capsule fails, you risk losing them.  See #Q3 in Using Time Machine with a Time Capsule for details.
    Then can i access these files only on the time capsule without connecting it?
    Not sure what you mean.  You have to connect a computer, either via Ethernet cable or wirelessly, to read or write to the disk. 

  • How can i get the time to appear on my stored data in notepad

    Hi all,
    I was wondering how can i get the time to appear on my stored data in notepad? I saw an example before but i forgotten which example was it.. Any ideas??
    holla
    Attachments:
    TextFile1.txt ‏3 KB

    Hi
    Im using Labview 8.2. Currently it just shows the data without the time. Im not sure what to do. It works perfectly though. I just want the time to appear on my notepad along with my data
    holla
    Attachments:
    Testing1.txt ‏1 KB
    Untitled 231_LV80.vi ‏23 KB

  • How can i get the time and result together show in one Array or in Cluster?

    hello everyone i am a new user .I want to get the time and voltge form a Generater. How can i get the time and result together show in one Array or in Cluster?When i selecte the first(or third...) result then in the front panel display the time and the voltge.Thank you!
    I post the time and voltge NOT together photo
    Attachments:
    12345.GIF ‏54 KB

    You can create an array of clusters with one element being the time and the other being the voltage, like so (using the "Get Waveform Components" function):
    Message Edited by smercurio_fc on 10-17-2007 03:15 PM
    Attachments:
    pic.PNG ‏11 KB

  • Query on 0TCT_MC01 to get the last used date of a query

    Dear All,
    I tried to create a query on 0TCT_MC01 to get the last used date of a query.
    Since we do not have readily available key figure for Last used date, could any one help me out to achieve this result?
    I am interested to find the old queries which are not being used anymore.
    Thanks in advance.

    You can get the info from the below tables
    if you are working with BW 3.5 you can look in table RSDDSTAT in BI 7.0 it is RSDDSTAT_OLAP.
    Make a selction on the infocube and the OLAP Statistic Object which is the query ID and execute. Then you should see how often the query was executed, by whom and which date/time.
    in field Statistics Object Name Query ID you type in the tech name of the query
    from the Counter for statistics event calls -- will give the count... no of times the query used least the count lesser the query is used.
    Regards
    KP
    Edited by: Konduru Prashanth. on Dec 22, 2011 2:44 PM

  • Getting the time of a particular keyframe

    Hi There,
    I took a look at the Scripting Guide, but after a cursory search + read couldn't find the answer to my question there, so I thought I would reach out here.  How can I get the time value for a keyframe in any given property?  I know I can iterate through keys using the .numKeys value, but what is the code to use in order to  retrieve the time of the key while iterating.
    Here's some pseudo code for how I'm thinking about it:
    numPosKeys = lyr.transform.position.numKeys;
    for (var i=1; i <= numPosKeys; i++)
         timeOfKey = {//not sure how to do this, or if it is possible};
         //do something with timeOfKey
    Thanks for your time and help!
    --Arie

    timeOfKey = lyr.transform.position.keyTime(i);
    (methods to retrieve key info start with 'key', and methods to set info start with 'set' and end with 'AtKey').
    Xavier.

  • Anyone know how to get current time using Java?

    Hi,
    do anyone know how to use system.currentTimeMillis() to get the current time?
    I know that system.currentTimeMillis() get the time between current time and midnight, January 1, 1970 UTC. but how to use it to get the current time format?
    Thank you very much.

    Hi,
    do anyone know how to use system.currentTimeMillis()
    to get the current time?
    I know that system.currentTimeMillis() get the time
    between current time and midnight, January 1, 1970
    UTC. but how to use it to get the current time format?
    Thank you very much.
    long timeInMillis = System.currentTimeMillis();
    Calendar c = Calendar.getInstance();
    c.setTime(timeInMillis);
    Date d = c.getTime();And format using SimpleDateFormat:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-mm-yyyy HH:mm:ss");
    String formattedDateString = sdf.format(d);

  • How can i get the time detail with messageDateField ?

    Is there any common way of getting the time info with messageDateField ? As far as i research, there is no way of adding the time support of messageDateField such that it can be enabled by setting a parameter to true like getTime="true". Thanks.
    Fatih ER

    Sebahattin,
    You can display the time component by adding the timeStyle attribute:
    <onSubmitValidater>
    <date dateStyle="shortish" timeStyle="short" />
    </onSubmitValidater>
    Unfortunately, in the current release, when you save the date, the time will be lost. We have fixed this for the next release. As a work around, you can continue the route you have chosen with a separate time field.
    To get the time value in your entity object you can add a transient attribute "time" to both your VO and EO. In the UIX page, you create a field with the same name and set persistent="true". Now, the JHeadstart save process will simply send the time field to your EO through your VO, and you can use it to add the time component to your date field.
    Steven davelaar.

  • My iPhone has just started getting the time wrong

    My iPhone has just started getting the time wrong. Whether I have 'set automatically' on or off, it still sets the clock and hour ahead of the real time. If I reset it correctly, within 10m it has incorrectly reset it. It is amazingly frustrating!

    Hello justveils,
    It sounds like you are not able to erase just one letter when backspacing.  I recommend following steps in the tutorial below to address an issue like this (you can skip step 2 "Recharge iPhone" because it's not related to this issue).  I think the step to reset your iPhone my be particularly useful in this scenario:
    To reset iPhone, press and hold the Sleep/Wake button and the Home button at the same time for at least 10 seconds, until the Apple logo appears.
    You can find the full tutorial here:
    Frozen or unresponsive iPhone
    http://www.apple.com/support/iphone/assistant/phone/
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • How to get the workcentres used in the routing out of 2 alternate routings

    Dear All,
    I would like to know how to get the workcentres used in the routing out of 2 alternate routings.
    I referred PLKO got the Task List Type (PLNTY), Group(PLNNR), Group Counter(PLNAL), Plant(werks).
    I passed this in to PLPO, The problem in PLPO is we don’t have the distinguishing field Group Counter(PLNAL), so I am getting all the ARBID including both alternates.
    How to get the ARBID with respect to Groupcounter 1 alone.
    If a get the ARBID , I can get the ARBPL from CRHD.

    HI,
    Use PLAS Table also.  you have to use PLKO> PLAS> PLPO.
    Pass PLNNR & PLNAL in PLAS and get PLNNR & PLNKN.
    Then pass these into PLPO.
    work centers from CRHD
    Regards,
    Krishna Mohan
    Edited by: Krishna Mohan N on Jan 31, 2008 12:28 PM

  • How do I get the time stamp on photo?

    How do I get the time stamp on photo? Someone texted me a few pics and it does not show date taken in iphoto. How can I find this. They were taken with a iphone. Thx

    Here's a screenshot of what Keith is referring to:
    Note the cursor over the date which brings up the 3 important dates for the photo.
    OT

Maybe you are looking for