Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TCP IP socket goes up and down

TCP IP socket goes up and down

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminc++helpquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahitan
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • N 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

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      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 <

      N 1 Reply Last reply
      0
      • C Code o mat

        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 <

        N Offline
        N Offline
        nahitan
        wrote on last edited by
        #3

        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

        C 2 Replies Last reply
        0
        • N 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

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          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 <

          N 1 Reply Last reply
          0
          • C Code o mat

            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 <

            N Offline
            N Offline
            nahitan
            wrote on last edited by
            #5

            Server, and I get that on server always, For client as I don't have the code don't know what happens! Thanks,

            C 1 Reply Last reply
            0
            • N 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

              C Offline
              C Offline
              Code o mat
              wrote on last edited by
              #6

              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 <

              1 Reply Last reply
              0
              • N nahitan

                Server, and I get that on server always, For client as I don't have the code don't know what happens! Thanks,

                C Offline
                C Offline
                Code o mat
                wrote on last edited by
                #7

                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 <

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups