Jump to content
  • Advertisement
Sign in to follow this  
etsuja

listen error *ignore this post, found answer*

This topic is 4445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!