We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 367 - Socket returned by accept is non-blocking on some OSes
Summary: Socket returned by accept is non-blocking on some OSes
Status: RESOLVED FIXED
Alias: None
Product: SDL_net
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All Solaris
: P2 major
Assignee: Sam Lantinga
QA Contact:
URL:
Keywords:
: 381 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-11-18 16:22 UTC by Joakim L. Gilje
Modified: 2007-07-14 22:56 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim L. Gilje 2006-11-18 16:22:55 UTC
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.
Comment 1 Ryan C. Gordon 2007-07-03 03:21:10 UTC
*** Bug 381 has been marked as a duplicate of this bug. ***
Comment 2 Sam Lantinga 2007-07-14 22:56:06 UTC
This is fixed in subversion revision 3280, thanks!