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. Client Socket and connection problem

Client Socket and connection problem

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminhelpquestion
10 Posts 3 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 was wondering if you have a client socket that is supposed to initiate the connection to a server, how often the client sends the request? I have a client socket and it seems that there is some wireless communication problem so that the socket connection to the server goes down and the client socket sends the request for connection every 1/100 second. Does it make sense to you guys? I log every messages that go through the sockets and I see the connection request every 1/100second and it seems that the connection is establishing and then I see WSAENOTSOCK message and the socket gets closed and the establishes and I get WSAECONNRESET message and it continues until the connection stays up and open. Does anybody know whatis going on here?? Thanks,

    M 1 Reply Last reply
    0
    • N nahitan

      Hi there, I was wondering if you have a client socket that is supposed to initiate the connection to a server, how often the client sends the request? I have a client socket and it seems that there is some wireless communication problem so that the socket connection to the server goes down and the client socket sends the request for connection every 1/100 second. Does it make sense to you guys? I log every messages that go through the sockets and I see the connection request every 1/100second and it seems that the connection is establishing and then I see WSAENOTSOCK message and the socket gets closed and the establishes and I get WSAECONNRESET message and it continues until the connection stays up and open. Does anybody know whatis going on here?? Thanks,

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      It depends on the protocol. If you're using TCP then you could research the TCP protocol and see how it handles reconnects. I suppose that could be implementation specific - Microsoft's TCP implementation may be different then others. How are you seeing the socket error codes? These aren't part of the protocol. The WSAENOTSOCK error isn't good - that's usually (always?) from a programming error. Mark

      "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

      N 1 Reply Last reply
      0
      • M Mark Salsbery

        It depends on the protocol. If you're using TCP then you could research the TCP protocol and see how it handles reconnects. I suppose that could be implementation specific - Microsoft's TCP implementation may be different then others. How are you seeing the socket error codes? These aren't part of the protocol. The WSAENOTSOCK error isn't good - that's usually (always?) from a programming error. Mark

        "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

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

        I have done this t get the Error: BOOL Socket::StoreError( INT Error ) { BOOL RetCode; RetCode = FALSE; __try { if( Error != 0 ) { ......... switch( Error ) { case WSAEACCES: wsprintf( ErrBuff, "WSAEACCES" ); break; case WSAEADDRINUSE: wsprintf( ErrBuff, "WSAEADDRINUSE" ); break; case WSAENOTSOCK: wsprintf( ErrBuff, "WSAENOTSOCK" ); break; ........... ........... if(( strlen( ErrBuff )> 0 )&&( RetCode )) { LogError( "Socket", "StoreError", "%s, %s", sName, ErrBuff ); } I also check the status of the socket in the data link layer and write it down to the log.

        M 1 Reply Last reply
        0
        • N nahitan

          I have done this t get the Error: BOOL Socket::StoreError( INT Error ) { BOOL RetCode; RetCode = FALSE; __try { if( Error != 0 ) { ......... switch( Error ) { case WSAEACCES: wsprintf( ErrBuff, "WSAEACCES" ); break; case WSAEADDRINUSE: wsprintf( ErrBuff, "WSAEADDRINUSE" ); break; case WSAENOTSOCK: wsprintf( ErrBuff, "WSAENOTSOCK" ); break; ........... ........... if(( strlen( ErrBuff )> 0 )&&( RetCode )) { LogError( "Socket", "StoreError", "%s, %s", sName, ErrBuff ); } I also check the status of the socket in the data link layer and write it down to the log.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Ok, but what calls this Socket::StoreError() method? If you are getting a WSAENOTSOCK error somewhere then that means a socket op is being attempted on a handle (SOCKET) which isn't a known socket. Not good :)

          "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

          N 1 Reply Last reply
          0
          • M Mark Salsbery

            Ok, but what calls this Socket::StoreError() method? If you are getting a WSAENOTSOCK error somewhere then that means a socket op is being attempted on a handle (SOCKET) which isn't a known socket. Not good :)

            "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

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

            One other question, 1. Let say my socket is connected to the server 2. I turn off the wireless link of my computer and there should be no socket connection. 3. Neither client socket nor server socket understand that the connection is gone until I re connect the wireless switch in my computer and get connected to the network, at that time my application sees the connection went down and came back up. And it is the time that sometimes I see those error messages until I restart one of the application and have the socket connected again. What do you think?

            M 1 Reply Last reply
            0
            • N nahitan

              One other question, 1. Let say my socket is connected to the server 2. I turn off the wireless link of my computer and there should be no socket connection. 3. Neither client socket nor server socket understand that the connection is gone until I re connect the wireless switch in my computer and get connected to the network, at that time my application sees the connection went down and came back up. And it is the time that sometimes I see those error messages until I restart one of the application and have the socket connected again. What do you think?

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              I think then that the connection is closed and needs to be reconnected. That would explain the NOTSOCK error since the socket became invalid at some point. That also explains the WSAECONNRESET error. When you get that error the connection is closed. That means you should close the socket and reconnect.

              "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

              M 1 Reply Last reply
              0
              • M Mark Salsbery

                I think then that the connection is closed and needs to be reconnected. That would explain the NOTSOCK error since the socket became invalid at some point. That also explains the WSAECONNRESET error. When you get that error the connection is closed. That means you should close the socket and reconnect.

                "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                M Offline
                M Offline
                Mauro Leggieri
                wrote on last edited by
                #7

                The NOTSOCK error is because somewhere in your code you are closing the socket handle. If the wireless connection gets down, in a period of time you will receive de connection reset error when the system detects the broken connection but the socket handle still remains valid so you should not receive notsock errors unless you closed the handle. Best regards, Mauro.

                M N 2 Replies Last reply
                0
                • M Mauro Leggieri

                  The NOTSOCK error is because somewhere in your code you are closing the socket handle. If the wireless connection gets down, in a period of time you will receive de connection reset error when the system detects the broken connection but the socket handle still remains valid so you should not receive notsock errors unless you closed the handle. Best regards, Mauro.

                  M Offline
                  M Offline
                  Mark Salsbery
                  wrote on last edited by
                  #8

                  Good point. Something is happening to the socket somewhere, but we haven't seen any code so who knows? Thanks! Mark

                  "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

                  N 1 Reply Last reply
                  0
                  • M Mark Salsbery

                    Good point. Something is happening to the socket somewhere, but we haven't seen any code so who knows? Thanks! Mark

                    "Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")

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

                    Thanks for the tips,

                    1 Reply Last reply
                    0
                    • M Mauro Leggieri

                      The NOTSOCK error is because somewhere in your code you are closing the socket handle. If the wireless connection gets down, in a period of time you will receive de connection reset error when the system detects the broken connection but the socket handle still remains valid so you should not receive notsock errors unless you closed the handle. Best regards, Mauro.

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

                      Thanks for the tip. Best regards

                      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