T
T
TheRevan2016-10-09 12:10:33
Java
TheRevan, 2016-10-09 12:10:33

How does client-server interaction take place in different languages?

Interested in the following question:
Let's say there is a client - a program written in C ++, and there is a server - written in java. How will the server and client communicate? let's take an example of a game...
There is a character (on the client) that moves along x, y coordinates. How will C++ send data to the java server using some method and how will C++ know the answer (in this case, true or false) about the possibility of moving the character to a given coordinate? Really through POST GET requests? what types of data can be transferred in this way? Or can everything be passed in JSON format or an analogy? Recommend normal literature on this topic or video tutorials

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GavriKos, 2016-10-09
@TheRevan

What you are trying to formulate is called "interaction protocol". Tobish rules on which communicate the client and the server. It can be either binary or text (yes, JSON). The protocol describes what, in what format and sequence will be transmitted. For example - "if 3 bytes of the packet is 10, then this is a request for coordinates. The coordinates are transmitted in the response packet in bits 3 and 4."
And about GET / POST - you can use them if the speed is not critical and there are few requests. It is possible (and in your example it is necessary) - sockets.

Станислав Макаров, 2016-10-09
@Nipheris Куратор тега C++

Protocol Buffers

S
sitev_ru, 2016-10-09
@sitev_ru

Я бы сделал на сокетах

Александр, 2016-10-09
@NeiroNx

Взаимодействие идет посредством TCP/IP. Http(POST GET) - это протокол над протоколом TCP, он содержит много не нужной информации для игры.
Вам нужно смотреть в сторону простых TCP подключений - сервер создает слушающий сокет для определенного порта, клиент к нему подключается - сервер видит подключение и вызывает обработчик нового подключения. Начинается обмен данными - чем проще бинарный формат тем меньше канал связи потребуется и "пинг клиента" будет ниже. Алгоритм реализации примерно одинаковый что для C++ что для Java.
начать нужно хотя бы с такой статьи https://habrahabr.ru/post/209144/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question