Non-blocking accept() function for sockets

BlitzMax Forums/BlitzMax Programming/Non-blocking accept() function for sockets

RexRhino(Posted 2005) [#1]
Ok, I have created a Socket server... The only problem I have is that the Accept() statement blocks... meaning that while it is waiting for a connection, nothing in the program happens.

There doesn't appear to be any command defined for setting the blocking status. In unix you would use fcntl with the proper flag, but that doesn't work on windows.


skidracer(Posted 2005) [#2]
See the ioctlsocket command.


SSS(Posted 2005) [#3]
alternitavely you could look at Antony's multithread module and then accept sockets in different thread?


flying willy(Posted 2005) [#4]
I wouldn't put a lot of trust in multithreading. Needlessly complex.


marksibly(Posted 2005) [#5]
Hi,

'select_' with a 0 timeout should let you poll a socket.


skn3(Posted 2005) [#6]
select_ ???

whats that...


RexRhino(Posted 2005) [#7]
Thanks for the info Mark... I figured that select_ would do something like that... but unlike the other commands, it was hard to figure it out from the C and Python tutorials how it translates to Blitz.

A brief explanation of how select works in Blitz would be greatly appreciated (it isn't covered in the docs)!


skidracer(Posted 2005) [#8]
msdn is you friend:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/select_2.asp


Zenith(Posted 2005) [#9]
MSDN is _NOT_ your friend! :]


RexRhino(Posted 2005) [#10]
MSDN doesn't explain what the blitz equivalent to a "set of sockets" is. Is it a TList, an array... Do I write to a bank with Int values and pass the pointer?

And how do figure out what WSAENETDOWN constant is? Or the WSAENOTSOCK constant?


skn3(Posted 2005) [#11]
Ooooo its a winsock function. I was looking through everything getting puzzled XD. Classic ¬_¬