Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

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

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 hsine   Members   

112
Like
0Likes
Like

Posted 11 January 2013 - 08:33 PM

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 ?
 





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.