September 22nd, 2002, 12:43 AM
connection reset problem
I am getting a socket error while trying to send a sequence of strings to a server I created. Im useing Winsock as I am programing in Windows.
the error returned by WSAGetLastError was number 10054:
#define WSABASEERR 10000;
#define WSAECONNRESET (WSABASEERR+54);
Which acording to google indicates a connection reset. Obviously this must mean my server is not receiving the data.
I have an array of pointers:
and my server loops 6 times and each time it assignes the data retrived into a buffer, and then into my array.
The client simply loops 6 times each time asking for a string and sending it.
This way my theory is I will be able to pass a array of pointers from my client to the server.
the client sucessfully sends 3 strings, then I get the error reported by my error handler.
Acording to http://www.innovation.ch/java/HTTPClient/errors.html
java.net.SocketException: Connection refused
(connecting to the local host) The server is not running (nobody is listening on the specified port).
I am programing in C but would assume that this error is global and would apply to all languages.
I have verified with my firewall status that before the error the server is indeed listeining, and conected in, and the client is conected out.
After the error ocures, my client window closes,.
Are there any typical causes of connection reset?
September 22nd, 2002, 01:44 PM
Connection reset will typically happen if whatever's on the other end of the connection goes away unexpectedly - typically resulting from a modem hangup, machine reboot or simply a network problem that persists long enough to reset the connection.
Another common cause (these days) is a connection which has been timed out by an intervening NAT firewall - usually when no traffic has been sent for a while.
As TCP connections don't usually send keep-alives by default, you may get this error when trying to send a message down the socket. This is completely normal, your code should handle it the same as if the client had hung up.
When writing something to be used over the internet, these connection resets are very common - your application should be able to handle them robustly on both the client and server end - the server should assume the client has gone away, the client may wish to try reconnecting - or prompt the user to reconnect.
In some protocols, the server will keep a "disconnected" session active for a while, in case the client decides to reconnect following a broken connection. For online games etc, this allows a conn reset to be handled without abandoning the game.
To attempt to avoid this problem, keep-alives can be enabled. I don't know how to do this but I'm sure it can be found out easily.
September 23rd, 2002, 11:46 PM
Thank you, I will find out how to enable keep alive so my server does not reset the conection.
My error handler so far only prints the error number to the screen and shutsdown winsock.