Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » UDP connection
Re: UDP connection [message #36022 is a reply to message #36021] Thu, 19 April 2012 15:25 Go to previous messageGo to previous message
Zbych is currently offline  Zbych
Messages: 326
Registered: July 2009
Senior Member
Take a look at Server.cpp in urr.

You need to open socket and bind:

	sas_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if(sas_sock < 0) {
		RLOG("SAS SOCK ERROR");
		goto End;
	}
	srvadr.sin_family = AF_INET;
	srvadr.sin_port = htons(SAS_PORT);
	srvadr.sin_addr.s_addr = htonl(INADDR_ANY);
	if(bind(sas_sock, (sockaddr *) &srvadr, sizeof(srvadr)) != 0) {
		RLOG("SAS SOCK BIND ERROR");
		goto End;
	}

	len = 1;
	setsockopt(sas_sock, SOL_SOCKET, SO_BROADCAST, (const char *)&len, sizeof(len)); 



and then wait for input:

		struct sockaddr address;
		socklen_t addr_size = sizeof(address);
		ssize_t len = recvfrom(sas_sock, (char *)buffer, buff_len, 0, &address, &addr_size); 

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Linux external libs
Next Topic: Zooming layout in Windows
Goto Forum:
  


Current Time: Thu May 09 04:06:54 CEST 2024

Total time taken to generate the page: 0.02628 seconds