dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Socket closes for no reason (WSAGetLastError() = 10057)

  1. #1
    Join Date
    Sep 2010
    Posts
    1

    Socket closes for no reason (WSAGetLastError() = 10057)

    So the accept returns a non-negative value (which means it works).

    As soon as recv() is called, I get a WSAGetLastError() = 10057 which means the socket was shutdown(?).

    Am I missing anything? Why would the socket close by itself?

    Code:
    char recvBuff[256];
    
     while (true)
    		 {
    			listen(s,10);
    			int aRet = accept(s,NULL,NULL);
    		
    			int nRet = recv(s,recvBuff,256,0); 
    
    			cout << "Error:" << WSAGetLastError() << endl;
    		
                            count << endl << "Message received: " << recvBuff; 
    			
    			cout << endl << "Socket accept errcode: " << aRet;
    			cout << endl << "Socket receive errcode: " << nRet;
    
    		 }
    	
    		 int cRet = closesocket(s);

    Any hint is appreciated.

  2. #2
    Join Date
    Jul 2009
    Posts
    154

    Re: Socket closes for no reason (WSAGetLastError() = 10057)

    your use of those functions are all wrong, take a look again at how to use them on MSDN

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




On-Demand Webinars (sponsored)