Hello!
I want to implement a server-client UDP connection
over SunOS that uses broadcast. For now I think
that an implementation for this will look like :
(For server) :
1) Create socket
s = socket(AF_INTE,SOCK_DGRAM,0);
2) Set broadcast.
int enable = 1;
setsockopt(s,SOL_SOCKET,SO_BROADCAST,&enable,sizeof(enable));
3) Bind one port
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(1234);
bin(s,(struct sockaddr *)&sin,sizeof(sin));
5) LAN use INADDR_BROADCAST (not care of ioctl...)
dst.sin_family = AF_INET;
dst.sin_port = htons(1234);
dst.sin_addr.s_addr = INADDR_BROADCAST;
6) Send message to all listening clients...
sendto(s,buf,beflen,0,(struct sockaddr *)&dst,sizeof(dst));
Is this correct??? Anyone who have some fine example?
(For client(s)) :
Step 1, 3 and then just listen on broadcast, or what?
How will this initialization look like.
Please help.
Thanks.
Greetings Fredrik.