c++ - Combine multiple variables to send as a udp packet -


i need send packet of data on udp connection in c++. first message need send built of 2 32 bit integers , 64 bit integer. best way combine multiple variable types 1 block of data ready sending on udp connection?

it depends on requirements network. care endianness? if do, should use not serialisatioin, safe 1 in regards endianness.

generally, each class/struct sendable through network should have special methods or overloaded operators stream them in , out. you'll have use macros/functions hton/ntoh streaming primitive types eg int, int64, float, double etc.

upd: if network endpoint applications run on different platforms/compilers, may have different sizes of int, long, short etc. when serialising, you'll have convert integers predefined types sizes guaranteed same on supported platforms.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -