The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
avoid sending udp packages to yourself
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
Maybe its a generally network question.
Im sending packages via broadcast two other players. Some of the received packages are my owns.
Is it possible to avoid this overhead by setting one of the packet attributes for example?
avoid sending udp packages to yourself
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
I'd recommend sending either a uuid or a combination of a small hash and message id/timestamp.  Uuid would be nice to identify clients, but a small hash and message id can do the same job.
But also be aware that if you are having multiple clients broadcasting frequently, it might be a sign off a strange/bad design, depending on what you're trying to do.  On that not, what are you trying to achieve?
avoid sending udp packages to yourself
MrOzBarry


Joined: 26 Jun 2010
Posts: 620
Sorry my new email so cut off some of your message my initial read.
Probably what you should do is assign a uuid to the payer hosting the game, which would become the 'game id.'. The server broadcasts this every few seconds, which in turn advertises the IP, and your want to send the game port if it's unknown, as well as some type of game identifier so other applications that may be listening for similar broadcasts can ignore it.
This is the type of strict I'd use for broadcasting:
struct GameBroadcastPacket
{
  char identity[3];  // Small abbreviation of your game name
  long port;
  char game_id[32]; // probably could be shorter, but guid v4 is 128bit/32 bytes long
};



When a client receives this, they can trace the host IP from the packet, and the host can ignore any broadcast with its own have id.

On Mon, 12 Jan 2015 5:21 am Meldryt wrote:
Quote:



Maybe its a generally network question.
Im sending packages via broadcast two other players. Some of the received packages are my owns.
Is it possible to avoid this overhead by setting one of the packet attributes for example?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Meldryt


Joined: 22 Oct 2014
Posts: 36
Location: Munich
Thanks, i know how to do handle with incoming packages. I think i found what i want. I just have to bind all the ipaddresses that i want to broadcast to, to a channel.