TcpClient performance issue

  • Thread starter Thread starter Jimbo
  • Start date Start date
J

Jimbo

Hi People,
I have the following bit of code:

Console.WriteLine(DateTime.Now.ToString());
TcpClient tcp = new TcpClient(server, port);
Console.WriteLine(DateTime.Now.ToString());

When "server" is an IP address it takes approximately 5 seconds while
Windows works out if there is a Netbios name or not. However when
"server" is a Netbios name there is no delay and the Tcp connection is
made instantiously.

Is there anyway to stop Windows doing this and just getting it to talk
to the IP address it's been told to talk to? The irony is that the
Netbios name gets turned back into an IP address for TCP/IP packet
communication anyway.

Thanks
James.
 
Hi,

you have to use Dns.BeginResolve mehhod. a while later the call back is
fires where you can call EndResolve and connedt the socket. If you program
this way your application stay responcive as it should.

rgds, Wilfried
 
Back
Top