[ENet-discuss] Broadcast Messages through the LAN - Trying an implementation
David Orejuela
david.orejuela.esteban at gmail.com
Mon Mar 16 01:37:09 PDT 2009
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/567f1f81/attachment.htm>
More information about the ENet-discuss
mailing list