Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


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   -  Reputation: 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 ?
 


Sponsor:



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.



PARTNERS