# Avoid sending udp packages to yourself

**URL:** <https://discourse.libsdl.org/t/avoid-sending-udp-packages-to-yourself/21157>\
**Category:** SDL Development\
**Created:** [January 10, 2015, 5:11pm UTC](https://discourse.libsdl.org/t/avoid-sending-udp-packages-to-yourself/21157 "2015-01-10T17:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meldryt](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@Meldryt](https://discourse.libsdl.org/u/Meldryt)\
**Post date:** [January 10, 2015, 5:11pm UTC](https://discourse.libsdl.org/t/avoid-sending-udp-packages-to-yourself/21157/1 "2015-01-10T17:11:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alex\_Barry](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/alex_barry/32/515_2.png) [@Alex\_Barry](https://discourse.libsdl.org/u/Alex_Barry)\
**Post date:** [January 12, 2015, 1:24pm UTC](https://discourse.libsdl.org/t/avoid-sending-udp-packages-to-yourself/21157/2 "2015-01-12T13:24:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alex\_Barry](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/alex_barry/32/515_2.png) [@Alex\_Barry](https://discourse.libsdl.org/u/Alex_Barry)\
**Post date:** [January 12, 2015, 1:34pm UTC](https://discourse.libsdl.org/t/avoid-sending-udp-packages-to-yourself/21157/3 "2015-01-12T13:34:50Z")

</div>

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:

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  
SDL at [lists.libsdl.org](http://lists.libsdl.org)  
http:// [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)  
[lists.libsdl.org](http://lists.libsdl.org) [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)/  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)listinfo.cgi  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)/  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)[sdl-libsdl.org](http://sdl-libsdl.org)  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)
