Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 11 months ago.
cc3000 TCPSocketServer::accept timeout
In the new cc3000 library, the accept function of TCPSocketServer is set to block by default, but appears to have a very short timeout, so it looks like it has immediately failed.
It would be great if accept could be changed to block for longer or (preferably) indefinately
Also, returning a different error code for a timeout would be useful.
Regards
James
Hello James Masterman,
can you set sockopt to blocking? Report here the result.
Regards,
posted by Martin Kojtal 09 Dec 20130xc0170
Looks like I was wrong on this one. I set the socketserver to blocking and it works correctly!
During this investigation, I found one other minor issue with TCPSocketConnection::receive
I find that if a TCP client connects and then the connection drops out on the remote end for whatever reason (battery failure, device switched off, network issue etc) the socket does not detected the dropped connection if it's set to be non blocking. If I set the TCPSocketConnection to block, it works fine and detects the dropped connection. The issue is that in the receive function, when the socket is non-blocking, the function waits for data to become readable as below. However on a dropped connection of course no data ever appears.
if (!_blocking) { TimeInterval timeout(_timeout); if (wait_readable(timeout) != 0) return -2; }
The problem is the that the underlying socket is not checked so it will never know that the connection is dropped. When the socket is set to blocking, the timeout code is not entered and the socket is directly polled
int n = _cc3000_module->_socket.recv(_sock_fd, data, length, 0); if (n >= 0) { _is_connected = 1; } else { _is_connected = 0; }
At which point the dropped connection is detected and all is good.
The function needs a way to check for dropped connections for non-blocking sockets.
posted by James Masterman 10 Dec 2013Hello,
probably same as issue which was reported a while ago. Here's a link: http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/issues/3
There is an array _closed_sockets, which should be checked. If you have time, can fix this one, would be appreciated.
Regards,
posted by Martin Kojtal 10 Dec 20130xc0170