Home » Community » Newbie corner » UDP connection
Re: UDP connection [message #36022 is a reply to message #36021] |
Thu, 19 April 2012 15:25   |
Zbych
Messages: 327 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);
|
|
|
 |
|
UDP connection
By: Wolfgang on Wed, 18 April 2012 10:00
|
 |
|
Re: UDP connection
By: Zbych on Wed, 18 April 2012 10:10
|
 |
|
Re: UDP connection
By: Wolfgang on Thu, 19 April 2012 14:59
|
 |
|
Re: UDP connection
By: Zbych on Thu, 19 April 2012 15:25
|
 |
|
Re: UDP connection
By: Wolfgang on Thu, 19 April 2012 16:03
|
 |
|
Re: UDP connection
By: Zbych on Thu, 19 April 2012 20:32
|
 |
|
Re: UDP connection
By: Wolfgang on Thu, 19 April 2012 21:24
|
 |
|
Re: UDP connection
By: Zbych on Fri, 20 April 2012 08:14
|
 |
|
Re: UDP connection
By: Wolfgang on Fri, 20 April 2012 09:34
|
 |
|
Re: UDP connection
By: Zbych on Fri, 20 April 2012 10:16
|
 |
|
Re: UDP connection
By: Wolfgang on Fri, 20 April 2012 10:23
|
Goto Forum:
Current Time: Mon Apr 28 20:47:12 CEST 2025
Total time taken to generate the page: 0.00931 seconds
|