File diff r5974:e11b6f5200f9 → r5975:e1f08be8192a
src/network/core/udp.cpp
Show inline comments
 
@@ -24,33 +24,25 @@ bool NetworkUDPSocketHandler::Listen(con
 
{
 
	struct sockaddr_in sin;
 

	
 
	/* Make sure socket is closed */
 
	this->Close();
 

	
 
	this->sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 
	if (!this->IsConnected()) {
 
		DEBUG(net, 0, "[udp] failed to start UDP listener");
 
		return false;
 
	}
 

	
 
	/* set nonblocking mode for socket */
 
	{
 
		unsigned long blocking = 1;
 
#ifndef BEOS_NET_SERVER
 
		ioctlsocket(this->sock, FIONBIO, &blocking);
 
#else
 
		setsockopt(this->sock, SOL_SOCKET, SO_NONBLOCK, &blocking, NULL);
 
#endif
 
	}
 
	SetNonBlocking(this->sock);
 

	
 
	sin.sin_family = AF_INET;
 
	/* Listen on all IPs */
 
	sin.sin_addr.s_addr = host;
 
	sin.sin_port = htons(port);
 

	
 
	if (bind(this->sock, (struct sockaddr*)&sin, sizeof(sin)) != 0) {
 
		DEBUG(net, 0, "[udp] bind failed on %s:%i", inet_ntoa(*(struct in_addr *)&host), port);
 
		return false;
 
	}
 

	
 
	if (broadcast) {