[ENet-discuss] how to receive broadcast and reply to broadcast sender by using enet

enetcub enet_club at 126.com
Sat Jan 12 02:19:41 PST 2013


HI ALL:


once a client send broadcast to all host server in a same subnet, how can servers recevice the broadcast infomation and make reply to the client 
who has send the broadcast?

client :
----------------------------------------------------------------

void scan_servers_by_send_broadcast(){ENETAddress address;      address.host = ENET_HOST_BROADCAST;    address.port = BROADCAST_PORT  ENETSocket socket = ENET_socket_create(ENET_SOCKET_TYPE_DATAGRAM);ENET_socket_set_option(socket,ENET_SOCKOPT_NONBLOCK,1);ENET_socket_set_option(socket,ENET_SOCKOPT_BROADCAST,1);  ENET_socket_send(socket,address,&broadcast_buf,1);ENET_socket_destroy(socket);}



servers:
-------------------------------------------------------------
[Q: How can a server received broadcast information and tell client its ip address ?]


ENETSocket socket = ENET_socket_create(ENET_SOCKET_TYPE_DATAGRAM);ENET_socket_set_option(socket,ENET_SOCKOPT_NONBLOCK,1);ENET_socket_set_option(socket,ENET_SOCKOPT_REUSEADDR,1);ENET_socket_set_option(socket,ENET_SOCKOPT_BROADCAST,1);  ENETAddress serv_addr;    serv_addr.host=ENET_HOST_ANY;    serv_addr.port=BROADCAST_PORT;      // IS THIS RIGHT?ENET_socket_bind(socket,&serv_addr);...........


I DON'T KNOW WHAT SHOULD DO AFTER BINDING,,,,,  HELP ME PLEASE ,THANKS/...

any more, does BROADCAST_PORT shold be different from the SERVER_MAIN_SERVICE_PORT ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20130112/eff7f318/attachment-0001.html>


More information about the ENet-discuss mailing list