TCP IP socket goes up and down
-
Hi there, I have a C++ application on Windows based machine connecting to another Windows based application within a shared network (both servers connected to same firewall router)via TCP socket but time to time the socket goes up and down many times (80- 90 times a day) for couple of seconds I ran ping from both servers to ping each other and there is no problem with the ping, the two application send and receive many messages per second so there is not a single second with no inactivity between the two app. anybody can tell me what could be done to reduce the socket disconnection? One socket is forced to be server and listen on a specified IP and port and the other one is forced to connect as client to the same IP and port. Any suggestion is appreciated. Thanks, Nahitan
-
Hi there, I have a C++ application on Windows based machine connecting to another Windows based application within a shared network (both servers connected to same firewall router)via TCP socket but time to time the socket goes up and down many times (80- 90 times a day) for couple of seconds I ran ping from both servers to ping each other and there is no problem with the ping, the two application send and receive many messages per second so there is not a single second with no inactivity between the two app. anybody can tell me what could be done to reduce the socket disconnection? One socket is forced to be server and listen on a specified IP and port and the other one is forced to connect as client to the same IP and port. Any suggestion is appreciated. Thanks, Nahitan
Check the error codes when you detect a disconnect. Depending on your code, you probably will want to use GetLastError or WSAGetLastError, maybe that will shed some light on the issue, also, try logging outgoing and incoming data, maybe you have a bug somewhere and the stream stalls somewhere. Maybe show some code for us to look at.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <
-
Check the error codes when you detect a disconnect. Depending on your code, you probably will want to use GetLastError or WSAGetLastError, maybe that will shed some light on the issue, also, try logging outgoing and incoming data, maybe you have a bug somewhere and the stream stalls somewhere. Maybe show some code for us to look at.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <
Thanks for reply, here are some error logs I get: StoreError API Socket, WSAECONNRESET Closing socket due to error, Socket index = 0 API Socket, Socket is null. SocketIndex -1 generates invalid socket Server, socket link not found API Socket, Connection accepted from 192.168.0.51 all happens in 1-2 seconds the code is so big can't post in here. Thanks, Nahitan
-
Thanks for reply, here are some error logs I get: StoreError API Socket, WSAECONNRESET Closing socket due to error, Socket index = 0 API Socket, Socket is null. SocketIndex -1 generates invalid socket Server, socket link not found API Socket, Connection accepted from 192.168.0.51 all happens in 1-2 seconds the code is so big can't post in here. Thanks, Nahitan
Which side do you get this? The server or the client? And do you ALWAYS get it on that side?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <
-
Which side do you get this? The server or the client? And do you ALWAYS get it on that side?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <
-
Thanks for reply, here are some error logs I get: StoreError API Socket, WSAECONNRESET Closing socket due to error, Socket index = 0 API Socket, Socket is null. SocketIndex -1 generates invalid socket Server, socket link not found API Socket, Connection accepted from 192.168.0.51 all happens in 1-2 seconds the code is so big can't post in here. Thanks, Nahitan
On a side note, maybe try experimenting with the socket option SO_KEEPALIVE[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <
-
Server, and I get that on server always, For client as I don't have the code don't know what happens! Thanks,
Here[^] you can read the description for WSAECONNRESET: Connection reset by peer. An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET. My guess is that for some reason the client closes the connection (crashes?), or maybe "something" on the machine of the client closes the connection. Does the client maybe generate any log?
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world <