[ntp:questions] Re: This is tougher than I thought?
David J Taylor
david-taylor at blueyonder.co.not-this-bit.nor-this-part.uk.invalid
Sun Jan 22 13:42:59 UTC 2006
> I guess I can then use sockets from VC++ or even Visual Basic to send
> the data. I got a Send method there but I need to know what to dump in
> it : ). A packet isn't a string and isn't a number either. It's that
> structure you wrote above... I can probably send that... *scatches
> head*. I think it's the first thing I'll try once I finish this Beta 2
> version which presses me immensely right now since I self-imposed a
> deadline of 25 January to myself.
Yes, the "packet" is simply the packed data structure I referred to above.
You send the structure (one Send or Write command) and should get the same
structure back. As it's UDP, there's no need to set up the connection or
anything complicated like that. Fill in the server IP or FQDN, set the
protocol to UDP, the port to 123. In the data structure, fill it with
zeros, fill in the Flags field and the Originate Time (the first 32 bits
are Unix seconds, IIRC). Send the packet (you probably need the start
address and a length), wait for a reply with timeout (your socket
component should do all that), and read the time from the packet you get
A few lines of code, all being well.
In principle, you should be able to take almost any example which sends
and recieves a UDP packet, and just modify the port to 123 and the data
structure you use. COme back when you're ready to chat more.
By the way, one article describes using the DAYTIME protocol (port 13)
and this program claims to include NTP source for Visual Basic 6:
More information about the questions