CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  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
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,824

    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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  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
  •  





Click Here to Expand Forum to Full Width

Featured