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. Own client/server and 10053 problem

Own client/server and 10053 problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionsysadmin
5 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.
  • J Offline
    J Offline
    justin223
    wrote on last edited by
    #1

    Hello I got a client/server solution where I use IOPORTS in the server. Sometimes I get 10053 on WSASend/WSARecieve. Why do I get 10053 in the server, and how do I resolve it? Im not asking what the exact problem is, but to give me possible reasons that will help me to pinpoint the problem. "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error. " Doesnt help me that much.

    K 1 Reply Last reply
    0
    • J justin223

      Hello I got a client/server solution where I use IOPORTS in the server. Sometimes I get 10053 on WSASend/WSARecieve. Why do I get 10053 in the server, and how do I resolve it? Im not asking what the exact problem is, but to give me possible reasons that will help me to pinpoint the problem. "An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error. " Doesnt help me that much.

      K Offline
      K Offline
      keegan
      wrote on last edited by
      #2

      check out this article, it may have a remedy for you. *.*

      J 1 Reply Last reply
      0
      • K keegan

        check out this article, it may have a remedy for you. *.*

        J Offline
        J Offline
        justin223
        wrote on last edited by
        #3

        Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.

        J R 2 Replies Last reply
        0
        • J justin223

          Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.

          J Offline
          J Offline
          justin223
          wrote on last edited by
          #4

          oops. I do this before acceptex: m_sdClient = socket(AF_INET, SOCK_STREAM, 0); if (m_sdClient == INVALID_SOCKET) { m_nState = STATE_DEAD; WriteLog(LI_HIGH, "Couldnt reinit a socket\n"); return; } DWORD dwBytesRecvd;

          1 Reply Last reply
          0
          • J justin223

            Well. I think that the problem is that I do not disconnect correctly. This is my code for disconnect: if (m_nState == STATE_CONNECTED) { struct linger li = {0, 0}; // Default: SO_DONTLINGER shutdown(m_sdClient, SD_BOTH); setsockopt(m_sdClient, SOL_SOCKET, SO_LINGER, (char *)&li, sizeof(li)); } closesocket(m_sdClient); then i call acceptex: if (!AcceptEx(*m_psdListen, m_sdClient, &m_wsaInBuf.buf[0], SERVER_WORK_BUFFER_SIZE-(sizeof(sockaddr_in)+16)*2, sizeof(sockaddr_in) + 16, sizeof(sockaddr_in) + 16, &dwBytesRecvd, &m_ovIn)) { if (GetLastError() != ERROR_IO_PENDING) { m_nState = STATE_DEAD; closesocket(m_sdClient); return; } } Comments please.

            R Offline
            R Offline
            RobJones
            wrote on last edited by
            #5

            The client that connects to you needs to set their own linger options before they connect to you. Same with your server app (you should set linger before you bind the socket).. I'm not sure if you can set that option after the socket has already been connected or after it accepts a connection.. One other thing (and im not 100% sure) but I dont think you need to call shutdown on a socket when it doesn't linger.. I think you can close the socket right away to free up the socket resoruces..

            linger linger;
            linger.l_onoff = TRUE;
            linger.l_linger = 0;
            setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof(struct linger));

            if(bind(server,(sockaddr*)&local,sizeof(local))!=0)
            {
            if(server != INVALID_SOCKET)
            closesocket(server);

            MessageBox("Error Binding socket", "Socket Error", MB\_OK);
            

            }
            else
            {
            if(listen(server,10) != 0)
            {
            if(server != INVALID_SOCKET)
            closesocket(server);

            etc.....
            }

            Hope this gets you pointed in the right direction.. Rob Whoever said nothing's impossible never tried slamming a revolving door!

            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