Can Tcp/Ip "Accept() " Be Made "Non Blocking"
-
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry
-
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry
I think you may instead want to call
Listen()
in a separate thread.Listen()
is a blocking call (I believe you can specify a timeout) that waits for a client to connect.Accept()
is called when the connection is accepted. See this[^] MSDN link. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry
I think you should go by
select()
then. It takes a parameter which specifies a timeout for the operation. You can also check out theWSAAccept()
function. Rickard Andersson Here is my card, contact me later! UIN: 50302279 Sonork: 37318 -
I think you may instead want to call
Listen()
in a separate thread.Listen()
is a blocking call (I believe you can specify a timeout) that waits for a client to connect.Accept()
is called when the connection is accepted. See this[^] MSDN link. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.comRavi Bhavnani wrote: Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. Actually,
Listen()
simply sets up the socket for accepting connections, and accepts the size of the connection backlog (how many connections can be queued before they are accepted usingAccept()
).Accept()
is a blocking call that waits for a connection, and accepts it when one arrives.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry
-
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking?? Thanks. :) Jerry
-
Ravi Bhavnani wrote: Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted. Actually,
Listen()
simply sets up the socket for accepting connections, and accepts the size of the connection backlog (how many connections can be queued before they are accepted usingAccept()
).Accept()
is a blocking call that waits for a connection, and accepts it when one arrives.Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Sorry - my bad! :-O /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com