Thread: winsock

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    141

    winsock

    I keep getting error code 10057

    Code:
    #include <windows.h>
    #include <winsock.h>
    #include <string>
    #include <iostream>
    #pragma comment(lib, "Ws2_32.lib")
    
    
    int main ()
    {
    	int iResult;
    	WSADATA wsa;
    	WSAStartup(MAKEWORD(2,2), &wsa);
    
    	SOCKET s = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
    	struct sockaddr_in client;
    	
    	char text[] = "12345";
    
    	client.sin_family = AF_INET;
    	client.sin_addr.s_addr = inet_addr("_PRIVATE_");
    	client.sin_port = htons( 27015 );
    
    	iResult = connect( s, (SOCKADDR*)&client, sizeof( client ) ); 
    	iResult = send( s, text, strlen( text ), NULL );
    
    
    
    	std:: cout << WSAGetLastError() << std:: endl;
    
    
    
    }
    UPDATE:

    turns out the connection was refused, need to add error checking. -_-
    Last edited by bobbelPoP; 07-30-2008 at 12:33 PM.

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    45
    10057 "Socket is not connected."
    WSAENOTCONN (Winsock error number: 10057)
    Microsoft say this about Winsock error 10057 - WSAENOTCONN:

    A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using sendto) no address was supplied. Any other type of operation might also return this error—for example, setsockopt setting SO_KEEPALIVE if the connection has been reset.
    Full details of Winsock TCP error 10057 - WSAENOTCONN:

    Berkeley description: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket) no address was supplied.

    WinSock description: Same as Berkeley, and then some. An application attempted an input/output network function call before establishing an association with a remote socket (i.e. before calling connect() or accept()). It also has a specific meaning for setsockopt().

    Detailed description:

    setsockopt(): WinSock generates this error if you try to set SO_KEEPALIVE but the connection has already been aborted (e.g. a TCP reset received from remote host).
    http://www.winsock-error.com/Winsock...ot-connected-/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 08:32 AM
  2. Winsock Messaging Program
    By Morgul in forum Windows Programming
    Replies: 13
    Last Post: 04-25-2005, 04:00 PM
  3. Winsock - Where do i start?
    By Brain Cell in forum Networking/Device Communication
    Replies: 5
    Last Post: 02-14-2005, 01:39 PM
  4. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 12:11 PM
  5. winsock
    By pode in forum Networking/Device Communication
    Replies: 2
    Last Post: 09-26-2003, 12:45 AM