Client and server

I would like to create a connection between two applications. Should I use Client-Server or is there another way to communicate effectively with each other? Are there any ready-made C ++ network client server servers that are easy to use / reuse and implement?

Application # 1 <---> (Client) <---> (Server) <---> Application # 2

Thank!

+3
source share
2 answers

Client / server is a common architecture template (such as factory, delegation, inheritance, bridge - design patterns). What you probably want is a library that eliminates the boredom of packaging and unpacking your data in a format that can be sent by cable. I highly recommend you check out the protocol buffers library , which is widely used by Google and released as an open source. It automatically encodes / decodes data, and this allows programs written in different languages ​​to send and receive messages of the same type with all the dirty work done for you automatically. Protobuf deals only with the encoding, not with sending and receiving. You can use primitive sockets for this (highly recommended against this) orBoost.Asio asynchronous I / O library .

I must add that you seem to be confused about the meaning of the client and the server, as in the diagram you have an application talking to a client that is talking to a server that is talking to another application. This is not true. Your application is a client (or server). The client / server is simply the role that your application uses during communication. An application is considered a client when it initiates a connection or request, while an application is considered a server when it waits and processes incoming requests. Client / server are just conditions for describing application behavior.

+5
source

, , , , . , .

, , .

, .

.

+1

Source: https://habr.com/ru/post/1757270/


All Articles