TCP Connect Timeout

28 Oct 2012

Hi,

I am progressing with a project I started earlier in the year and am overcoming problems as they arise. Unfortunately I have now stumbled on one that I am struggling with.

My Mbed is acting as a client to transfer data to a server over TCP.

The Mbed will connect to the server immediately if the server is running, the problem I am having is that if the server is not running then the "sock.connect(IP,PORT)" command results in a very long timeout (about 15 seconds). The "sock.set_blocking" parameter does not seem to affect the connection request (it does work when you use "sock.receive" though).

My mbed needs to check a data buffer which can potentially become full in about 3 seconds, so I really need to set a timeout for the "sock.connect" command so that I can check the buffer and then attempt to connect again.

Is there any way to set a timeout on the "sock.connect(IP,PORT)" command ?

Any help on this would be much appreciated.

Regards,

Arthur