• Advertisement
Sign in to follow this  

how to receive broadcast and reply to broadcast sender by using enet

This topic is 1836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 ?
 

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement