473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Pb with TcpClient class and NTP server

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.
Nov 17 '05 #1
2 3388
Solved.

NTP servers only uses UDP protocol. A socket with ProtocolType.Udp
protocol works fined.
Nov 17 '05 #2
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,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Kirk" <no@spam> wrote in message
news:43***********************@news.free.fr...
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.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: מורדי | last post by:
Hi, I'm writing a client/server application in which the client send a series of screenshots to the server to be saved using the tcpclient. in most cases the first screenshot is transmitted ok...
1
by: alex002 | last post by:
Dear all, I am writing to a C# program to connect to the telnet server and getting data; however, I know that I can use either TCPClient and Asyncronous Socket to do the program. However, I...
7
by: user | last post by:
Hello How can i read IP of incoming connection when i have TcpClient for that connection ? Thanx
5
by: Jim W | last post by:
I have an ASP.NET app that has very slow connect times using TCPClient, or the Socket class, or even calling a COM object that uses C socket calls on certain similar XP SP2 boxes. On those...
4
by: Sebho | last post by:
Hello, i made an app that use sockets, based on this sample : http://www.microsoft.com/downloads/details.aspx?FamilyId=4B3215C0-62E7-4B84-9944-7582B8CD0125&displaylang=en i'have a problem, i...
1
by: hamil | last post by:
I am having trouble using the TcpListener and TcpClient classes. At the end of this post is server code that runs, and a class whose purpose is described below. I need to know when the client...
5
by: Nobody | last post by:
Hi all, I try to write a small client that can handle some TCP communication message. I was wondering how I could use the TcpClient class to manage it. At the first time, I don't want to...
4
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am wondering if I am using TCPClient class in C#, how to setup timeout value? Timeout I mean, when connects to server for the 1st time, and during <timeoutinterval, if no...
6
by: Bjoern Schliessmann | last post by:
Hello, I'm currently trying to implement a simulation program with Kamaelia and need a reliable TCP connection to a data server. From Twisted, I know that a method is called if the connection...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.