| Summary: | Socket returned by accept is non-blocking on some OSes | ||
|---|---|---|---|
| Product: | SDL_net | Reporter: | Joakim L. Gilje <jgilje> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P2 | CC: | adeason, jgilje |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Solaris | ||
*** Bug 381 has been marked as a duplicate of this bug. *** This is fixed in subversion revision 3280, thanks! |
After noticing server-side problems with TCP-communication on Solaris, IRIX and MacOS X, I modified the function SDLNet_TCP_Accept in SDLnetTCP.c to print whether or not the socket returned by accept is blocking using the code below: int currentMode = fcntl(sock->channel, F_GETFL, 0); printf("%d\n", currentMode & O_NONBLOCK); When executed, printf printed non-zero values. When tested under Linux, printf printed 0. So apparently the socket returned by accept is a blocking or non-blocking socket depending on the operating system. I fixed this by forcing the socket returned to block using the code below: int currentMode = fcntl(sock->channel, F_GETFL, 0); fcntl(sock->channel, F_SETFL, currentMode & ~O_NONBLOCK); I suggest forcing the socket returned by accept to block on all UNIX-platforms, as it will not make a difference on other operating systems like Linux where accept returns a blocking socket anyway.