Social Nerwork

Telephone us on: +353 87 223 6429 or email us using: info@ridgesolutions.ie
Telephone us on: +353 87 223 6429 or email us using: info@ridgesolutions.ie

Boost ASIO Simple UDP Send Packet Example

Boost.ASIO is great but if you don’t use it everyday it can be hard to remember how to use it to do even the simplest of things. I have included below a sample of simply sending a packet via UDP (ipv4), see the function called send_message(), this example code aims to be as minimal as it can be:

Those spouting software engineering dogma will often tell you to steer well clear of UDP for the usual, well understood reasons, but for a certain type of application where very low latency is important, it just can’t be beat!!

This is the bare-bones code, no error reporting etc. Also it won’t broadcast, to allow for broadcast you need to include the following two lines and supply a broadcast ip address when calling the function. Be careful if broadcasting a lot of data as it can really overload & mess-up network equipment!

LEAVE A REPLY

 

Google+