Pb with TcpClient class and NTP server

K

Kirk

Hello,

I'm trying to get the current date/time from a (S)NTP server. It works
with UdpClient class, but not with TcpClient class. I want to use
TcpClient because i can set timeout values for reading/writing operations.

The connect method generate a SocketException (10060 : timeout error) :

try
{
IPAddress address = IPAddress.Parse(TimeServer);
TcpClient client = new TcpClient();
client.Connect(address,123);
}
catch (SocketException e)
{
....
}

Have you an idea ?

Thanks in advance.
 
K

Kirk

Solved.

NTP servers only uses UDP protocol. A socket with ProtocolType.Udp
protocol works fined.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

If the server use UDP then there is nothng else you can do, you have to use
UDP.

Check the RFC for the protocol in question.

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top