G
G
German2019-02-16 14:11:05
Computer networks
German, 2019-02-16 14:11:05

Boost::asio how to write a TCP server for 2 clients?

I need 2 clients to be able to send data to the server, and the server redirects data from the 1st client to the 2nd and vice versa, how can I do this? Where to read?
In general, I am writing a simple online game for two, where can I read about it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petryaev, 2019-02-16
@Gremlin92

I won’t say for a boost, but you can create a socket listening port for example>=1000 and accept two connections, you will have to specify the (unique) client’s ID in the transmitted data and simply send data like the player’s actions as a send from one computer to another, that is, the whole economy should spin on the server (if the game is like Dota 2), then the success of one will depend on the delay of the transmitted packets (Internet speed). Store rooms there, and if it’s like a card game (then the generation of cards can be stored with one of the clients and stupidly transfer the player’s actions) . To do this, it is necessary to provide for a disconnection (pull out the Internet cable). It is necessary to create on kute, for example, an interface for a list of rooms online. And as I understand it, you decided to take a white address for the server part because you can’t get through nat? (Of course, with your level of knowledge,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question