We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,MDK MDK-Plus 7.18.0 over RTX5, compiled with ARM Compiler 6 in uVision 5
I'm using BSD API in non-blocking mode.
This is a complex project (Mongoose, https://mongoose.ws) but basically the problem is with a TCP server,
Open socket, listen, clients connect, accept, configure socket, read/write, and suddenly one of the sockets starts returning BSD_ESOCK to recv() until it is closed.
I have 10 TCP sockets, 10 BSD sockets, 1 listener, and I call `listen()` with a backlog of 5. I don't have more than 3 simultaneous connections, this mostly happens with the second socket after the third connection
Error checking removed for clarity (but done), these are the calls to MDK-Plus, is there anything wrong with this ?
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); bind(fd, &sa, slen); listen(fd, 5); setlocaddr(fd, loc); unsigned long on = 1; ioctlsocket(fd, FIONBIO, &on); rc = select((int) maxfd + 1, &rset, &wset, &eset, 1 second)) < 0) do { clear sa fd = accept(fd, &sa, &sa_len); } while (fd == BSD_EWOULDBLOCK) int on = 1; setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof(on)) setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *) &on, sizeof(on)) n = recv(fd, buf, len, MSG_NONBLOCKING); n = send(fd, buf, len, MSG_NONBLOCKING);