Re: Puzzled by ReceiveNetworkData().
Posted: Wed Feb 24, 2010 8:05 pm
You may be looking for a #WSAECONNABORTED
If the connection gets dropped during a send or recieve this error will be reported as a -1 on the send or receive and you have to look up the last error, for windows a call to WSAGetLastError_() and in linux you just look at errno (if there's a way in PB way to read the current processes errno in linux) the error constants are more of less the same for compatibility with Berkley sockets.
Creating a thread per connection and using semaphores is the a reasonable compromise, even if you're transferring small amounts of data, the cost of a signal is minimal compared to spawning a thread per receive, though that may be appropriate if you're only dealing with large transfers.
If the connection gets dropped during a send or recieve this error will be reported as a -1 on the send or receive and you have to look up the last error, for windows a call to WSAGetLastError_() and in linux you just look at errno (if there's a way in PB way to read the current processes errno in linux) the error constants are more of less the same for compatibility with Berkley sockets.
Creating a thread per connection and using semaphores is the a reasonable compromise, even if you're transferring small amounts of data, the cost of a signal is minimal compared to spawning a thread per receive, though that may be appropriate if you're only dealing with large transfers.