op*@du.se wrote:
My blocking TCP server hangs in the Accept method when the client
software sometimes gets an error.
I don't understand this; a blocking TCP server always "hangs" (more
normally described as "blocks") in Accept until a new client connects.
What do you mean by "when the client software sometimes gets an error" -
how is this causing the hang?
Are there any ways to stop this
blocking in the Accept method so I dont have to restart the server?
You could use the Poll method on the server socket in a loop, and only
call Accept when there really is a client connection pending.
I would rather not use threading or non-blocking sockets.
Your server will only ever be able to handle one connection at a time
then, if by 'non-blocking' you also include the style of polling
sockets, using timeouts etc.
Threading really makes blocking sockets a whole lot easier to work with
(although they don't scale much). And IMHO asynchronous sockets are
easier to work with than the poll / timeout style (though they take a
bit of getting used to). The polling / timeout style can make sense in
game scenarios though, where there are time budgets etc.
-- Barry
--
http://barrkel.blogspot.com/