TCP Connection Timeout ?

  • Thread starter Thread starter Axel Stallknecht
  • Start date Start date
A

Axel Stallknecht

Hi folks,

here is my (simple) code :
try
{
TcpClient tcpclnt = new TcpClient();
tcpclnt.Connect(IPAddress.Parse(ipAddress), intPort);
}
catch(SystemException e)
{
MessageBox.Show("Error : "+e.Message.ToString());
return false;
}

If it's not possible to connect to the specified IPAddress,
the connect needs between 45-60 seconds to get an exception.
Is there a possbility to have a shorter timeout, maybe with a
SocketOption, without use of a timer ?

cu
Axel
 
You might be able to change the time-out for *all* connections on the
device, but, no I don't think there's any per-socket way to change that.
Since the TCP/IP stack doesn't know how far away the device you are trying
to connect to is located, the time is chosen to assure that, if it does
time-out, the device really isn't there.

Paul T.
 
Hi Paul,

thankx for your answer.
You might be able to change the time-out for *all* connections on the
device, but, no I don't think there's any per-socket way to change that.
How can I change the timeout for all connections ?
All I have found is a ReceiveTimeout and a SendTimeout, but no
"General"-Timeout
that also affects the Connect Timeout.

cu
Axel
 
It would be a registry setting. I'll see if I can find the documentation
for it, but it's only available, as I recall it now, in Windows CE.NET 4.x
and later, so you'll have to tell us what device/version you plan to use it
on before we'd know if it will even have a chance of working...

Paul T.
 
Thanks for your help. I need it for WM2003.

Paul G. Tobey said:
It would be a registry setting. I'll see if I can find the documentation
for it, but it's only available, as I recall it now, in Windows CE.NET 4.x
and later, so you'll have to tell us what device/version you plan to use
it on before we'd know if it will even have a chance of working...

Paul T.
 
You can find the registry setting I was thinking at in MSDN. The page is
titled TCP/IPv4 and v6 Common Registry Settings and the setting I'm thinking
of is TCPMaxConnectRetransmissions. Cutting this from 2 to 1 should cut the
time-out in half. Cutting it from 2 to 0 should reduce it to 25% of the
original value.

Paul T.
 
Back
Top