[ENet-discuss] Broadcast Messages through the LAN - Trying an implementation

David Orejuela david.orejuela.esteban at gmail.com
Mon Mar 16 05:16:53 PDT 2009


 Another aproximation: Connecting broadcast

We can connect to a ENET_HOST_BROADCAST host so any Server will reply our
connect Request. Then we do all the server data information interchange and
disconnect from it.

Repeating this proccess we could obtain information from all the servers on
the LAN. But there are problems with this solution. When we do a
enet_host_connect, the server

can be the same that answered the last enet_host_connect, there are
unorderer responses.

Does somebody know a solution for it?


2009/3/16 David Orejuela <david.orejuela.esteban at gmail.com>

> Hi!
>
> First, I'm not much experienced with enet so sorry if I'm wrong in some
> parts of the following discussion.
>
> I've readed the following post: "How to send a broadcast message without
> connecting to any one?".
>
> I have the same problem, a client that search servers in a LAN, wich are
> not registred as enet peers of a host.
>
> So the default enet_host_broadcast function doesn't fit to my intentions.
>
> I must send a broadcast packet through the LAN network, so I coded the
> following:
>
>
>
> int
>
> enet_host_network_broadcast (ENetHost * host_origin, ENetPacket * packet)
>
> {
>
> ENetAddress target_address;
>
> ENetBuffer buffer;
>
> target_address.host = ENET_HOST_BROADCAST;
>
> target_address.port = host_origin->address.port;
>
> buffer.data = packet->data;
>
> buffer.dataLength = sizeof(packet->data);
>
> return enet_socket_send (host_origin->socket, &target_address, &buffer, 1);
>
> }
>
> In my "FindServers" client function, I use the new
> "enet_host_network_broadcast" enet function,
>
> sending a FIND_SERVERS_REQUEST message. But this message is never read by
> the server.
>
> Reading some posts in the mailing list I found a discussion about
> Multicast/Broadcast addresses (Giuseppe Greco giuseppe.greco at
> agamura.com
>
> Tue Sep 4 11:09:39 PDT 2007), that talks about broadcast datagrams
> discarding and shows the following code
>
> static int
>
> enet_protocol_handle_incoming_commands (
>
> ENetHost * host, ENetEvent * event)
>
> {
>
> ...
>
> if (peer -> state == ENET_PEER_STATE_DISCONNECTED ||
>
> peer -> state == ENET_PEER_STATE_ZOMBIE ||
>
> (host -> receivedAddress.host != peer -> address.host &&
>
> peer -> address.host != ENET_HOST_BROADCAST))
>
> return 0;
>
> ...
>
> }
>
> The questions are:
>
> I will be able to receive the FIND_SERVERS_REQUEST message if I modify
> "enet_protocol_handle_incoming_commands" removing "peer -> address.host !=
> ENET_HOST_BROADCAST" condition?
>
> Are there some kind of risks doing it?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20090316/337ba6da/attachment.htm>


More information about the ENet-discuss mailing list