I’m trying to use a normal TCPSocket
to connect to a server and download a simple file. I can create the socket just fine and open it, but connecting always fails with -3001
no matter what I do. The error means “would block”, but I don’t make the socket nonblocking anywhere, I even explicitly set it to be blocking. I do use other socket elsewhere and these are also non blocking, so could there be some kind of “leak” where settings leak from one socket to a totally separate instance?
NetworkInterface* net = NetworkInterface::get_default_instance();
if (!net) {
// no network interface
...
}
TCPSocket *socket = new TCPSocket();
nsapi_error_t result = socket->open(net);
if (result != 0) {
// init failure
....
}
socket->set_blocking(true);
result = socket->connect(SocketAddress("192.168.1.109", 1081));
if (result != 0) {
// connect error. This is always -3001
....
}
The error codes are:
num nsapi_error {
NSAPI_ERROR_OK = 0, /*!< no error */
NSAPI_ERROR_WOULD_BLOCK = -3001, /*!< no data is not available but call is non-blocking */
...