Advertisement

listen error *ignore this post, found answer*

Started by May 21, 2006 07:55 PM
1 comment, last by etsuja 18 years, 9 months ago
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]
Artist 1st - Programmer 2nd(I'll get some material linked here sometime to support these claims, haha)
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.
enum Bool { True, False, FileNotFound };
Advertisement
I tried to listen with UDP and you can't do that.
Artist 1st - Programmer 2nd(I'll get some material linked here sometime to support these claims, haha)

This topic is closed to new replies.

Advertisement