Sign in to follow this  
etsuja

listen error *ignore this post, found answer*

Recommended Posts

I'm having problems with lestening on a UDP socket here's my function so far it's pretty much copied from the windows examples. when I set the socket protocal to IPPROTO_UDP it gives me the WSAEPROTOTYPE error code, I've tried setting the protocal to 0 and it gives me the same message.
{

	int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
	if ( iResult != NO_ERROR )
	{
		AddString(TEXT("Error at WSAStartup()"));
	}

	
	if ( UDPSocket == INVALID_SOCKET ) 
	{
	UDPSocket = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP);

		AddString(TEXT("Error at socket():"));
		WSACleanup();
		return;
	}

	sockaddr_in service;

	service.sin_family = AF_INET;
	service.sin_addr.s_addr = htonl(INADDR_ANY);
	service.sin_port = htons(27015);

	if ( bind( UDPSocket, (SOCKADDR*) &service, sizeof(service) ) == SOCKET_ERROR )
	{
		AddString(TEXT("bind() failed."));
		closesocket(UDPSocket);
		return;
	}

	if ( listen( UDPSocket, 1 ) == SOCKET_ERROR )
	{
		AddString(TEXT("Error listening on socket."));
	}

	ofstream ErrorFile;
	ErrorFile.open("errors.txt", ios::app);
	ErrorFile << WSAGetLastError ;
	ErrorFile.close();


	WSACleanup();



[Edited by - etsuja on May 21, 2006 8:26:03 PM]

Share this post


Link to post
Share on other sites
You know, posting a follow-up that actually explains what you did wrong, and what the fix was, would be helpful for the community at large. If you're prepared to ask the community for help, you should also be prepared to give something back.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this