connect() timeout

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

connect() timeout

1,635 Views
Mike_d
Contributor IV

Hi,

 

I've got a server that is purposely behind a firewall to test the OPT_CONNECT_TIMEOUT.  I want it to give up after 5000ms but it will always try somewhere around seven times to SYN before quitting which takes around 1 minute and 40 seconds.  Is there soemthing else I need to modify to get it to stop trying after the connect timeout?

 

Thanks,

-Mike

Labels (1)
Tags (1)
4 Replies

593 Views
Joe2
Contributor II

Yes, 1 min and 40 seconds.  Same for me!!

 

I'm not sure if it's a 7x to SYN issue, as it doesn't seem matter what value I actually set connect timeout too.  I tried 1ms and still got a timeout of 1m 40s.

 

Anyone know a solution?

 

593 Views
michris
Contributor III

Hi,

I'm having this same problem.

I'm using MQX 4.0.0.

I see your issue was posted in Oct 2010, is there already a fix (workaround) for this? We are already Juli 2013 ??

I want a timeout of 10 sec on the connection function. (result = connect(sock, &addr, sizeof(addr));)

uint_32   sock;
uint_32   result;
uint_32   opt_length = sizeof(uint_32);
uint_32   opt_value;

opt_value = 10000;

result = setsockopt(sock, SOL_TCP, OPT_CONNECT_TIMEOUT, &opt_value, opt_length);

This results in a timeout after 1 min and 40 seconds

Any idea's ?

0 Kudos

593 Views
butok
NXP Employee
NXP Employee

Hi Guys,

I guess I found the reason.

The OPT_CONNECT_TIMEOUT socket option sets R2 timeout (defined in RFC 793).

According to the RFC793: "The value of R2 SHOULD correspond to at least 100 seconds." that equls your 1min 40 seconds.

Based the TCP source code, its values is checked to be not less than 100 sec (defined  by TCP_SENDTIMEOUT_MIN in tcp_prv.h).

Hope it is clear,

Andrey Butok

593 Views
michris
Contributor III

Hi Andrey,

I changed TCP_SENDTIMEOUT_MIN to 10000. (Instead of default 100000)

Now I have a timeout of 10 sec.

Thx

Christophe

0 Kudos