WinSock Client Error 10053
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: WinSock Client Error 10053

  1. #1
    Join Date
    Sep 2002
    Location
    Czech Republic
    Posts
    47

    WinSock Client Error 10053

    I'm working on a piece of networking code I want to use in a multiplayer game. The idea is that the machine that will run the client will sent keyboard status to the server which will reply with the information about the graphical objects the client should draw on its screen. I've studied how sockets work, compiled and tested the examples I found on the internet and all worked fine. The only problem is that I can't run the client code in a loop ( I need to send the keyboard status regularly to the server ). Always when the send() function is run the second time it fails with the error code 10053 -connection closed in host.

    this is the code I loop in the client:

    Code:
    while( ! kh.esc )
    {
     
       kh.ReadKeys();
       memcpy( buff, &kh, Len );
    
    
       if ( ( size = send( mySocket, buff, Len, 0 )) == -1 )
       {
          printf( "Error: %d\n", WSAGetLastError() );
          WSACleanup();
          return -1;
       }
    
        while ( ((size = recv( mySocket, buf, BUFSIZE, 0 ) ) != 0 ) && ( size != -1 ) )
        {
             text += buf;
             cout << text;             
        }
        
        if (size == -1)
        {
            cout << "Error receiving data" << endl;
        }
    
        
        Sleep( 100 );
        
    }

    thanx for help

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,865

    Re: WinSock Client Error 10053

    Error 10053 is Software caused Connection abort.

    See http://msdn.microsoft.com/en-us/libr...px#WSAENOTCONN

    What's the server code doing?

    Where has buf, buff and Len been set? What is text? You are using variables called buff and buf. If these are meant to be different it's not a good idea to have them so similary named for confusion of reading the code. Why are you assuming that buf is 0-byte terminated after the call to recv() when concatenating with text (is text type string?)
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  3. #3
    Join Date
    Sep 2002
    Location
    Czech Republic
    Posts
    47

    Re: WinSock Client Error 10053

    The problem was on the server side. I had put the accept() function inside the server loop. The code I posted is kind of messy because it contains both the original code and my modifications - I just used it to study how sockets work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center