[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Slow TcpClien.Connect() call

Alessandro

7/15/2004 11:16:00 AM

Hi,

I hope I am writing to the right newsgroup.
I am using the connect() method of the TcpClient class to connect to a host
node in a LAN.
If the host exists in the LAN the connection is established in few
milliseconds. And this is ok.
If the host is down or does not exist the connect() method throw an
exception in a very long time (20 seconds).... this is unacceptable for me.
My old code in Visual Basic 6 return me an error in a very short time.
I have tried also with a direct PC-PC connection with a cross-cable with the
same result.

Any ideas?

the following is my simple code.

Thank you in advance for the help

Alessandro

TcpClient tcp = new TcpClient();
try
{
tcp.Connect(host, port);
}
catch
{
....<enter here in about 20 seconds if host is unreachable>
}


1 Answer

Sunny

7/15/2004 2:29:00 PM

0

Hi,

this is not the right group, but anyway ...

Have you tried with TcpClient.ReceiveTimeout property?

If this is not working, you may try to invoke the connect method with an
async delegate, and wait the time you need. Search in this newsgroup for
a post "Zombie object". I have put there an example.

Sunny

In article <#uJyRzlaEHA.2516@TK2MSFTNGP10.phx.gbl>,
alessandro_m_@hotmail.com says...
> Hi,
>
> I hope I am writing to the right newsgroup.
> I am using the connect() method of the TcpClient class to connect to a host
> node in a LAN.
> If the host exists in the LAN the connection is established in few
> milliseconds. And this is ok.
> If the host is down or does not exist the connect() method throw an
> exception in a very long time (20 seconds).... this is unacceptable for me.
> My old code in Visual Basic 6 return me an error in a very short time.
> I have tried also with a direct PC-PC connection with a cross-cable with the
> same result.
>
> Any ideas?
>
> the following is my simple code.
>
> Thank you in advance for the help
>
> Alessandro
>
> TcpClient tcp = new TcpClient();
> try
> {
> tcp.Connect(host, port);
> }
> catch
> {
> ....<enter here in about 20 seconds if host is unreachable>
> }
>
>
>