Hello, writing here because I'm kinda stuck in understanding how to make network game...
I making my game engine from zero (yup, I'm stupid, because don't use engines which is made already, but just want to learn more basics about everything). Have made simple movement by input and with collision. Now I want to make I could "play" with my roommate.
What I want to make: game client could be server too. For example I launch game and my roommate connect to me (via my IP), and I would be server, and him would be client. As I move somewhere, my world position would be sent to all clients, and painted. As client moves, his position would be sent to server, and then echo to other clients and painted.
I started from making demo chat program for data (messages) sending. But without any good results. I have made server, which could receive only from one client, and can't send. When trying to make read from more then one, it stucks on accept, because for now used blocking sockets. Trying using C++ with winsocks2 (and for game using directx9).
What I think classes would have:
Client:
connect() {simple connect to server via ip}
send() {send data to server, and server echo to other clients}
receive() {get data from server}
sendToServer() {send data only to server}
disconnect(){send message to server and disconnect}
Server:
send(){send data to client}
receive(){get data from client/s}
echo(){send data to all clients}
kill(){send message to client to disconnect it}
maybe somebody could show any examples or what to read to understand better what I need?