C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 07-30-2008, 12:04 PM   #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.
bobbelPoP is offline   Reply With Quote
Old 07-30-2008, 01:53 PM   #2
EOP
Registered User
 
Join Date: Jan 2008
Posts: 45
Quote:
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-/
EOP is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 07:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22