Socket C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Socket C++

I want to write game with lan multiplayer. I use bsd-socket for chat, but I don't know how to pass player class through socket.

13th Dec 2017, 12:10 AM
Тимофей Солончук
Тимофей Солончук - avatar
1 Answer
+ 3
There are many ways, i gonna mention two. 1-easy) put your relevant object information into a bytearray and just send it like you did with the text messages. 2-elegant) pass a reference of your object to send and use sizeof(...) for your length. Take a look into boost alignment stuff if you are interested in this way.
13th Dec 2017, 1:09 AM
---
--- - avatar