M
M
maaGames2020-02-26 18:12:52
C++ / C#
maaGames, 2020-02-26 18:12:52

Client-server application?

I am writing a client-server application using the Poco library.
Within one PC, everything works fine, just as it would work through pipes, instead of sockets. Problems start when the client and server are on different PCs (it doesn't matter if they are on a local network or via the Internet).
The client must connect to the server via a socket forwarded in the router and firewall, after which a (third) program is launched on the server that performs long complex calculations, passing data to the client in the process. Those. the running program sends data to the client directly, and not through the server module, because there is a lot of data and often. But, after all, a separate port is allocated for it, which is not forwarded in the router ... And there can be more than one client at the same time, even on one PC there can be several active clients at once accessing the server via the same forwarded port ...
I don't understand how should I deal with ports? The system administrator can configure one specific port, but for interaction I need a bunch of ports, it turns out. And a bunch of clients will knock on the server on the same port, and I have no idea what to do with all this.
This is my first client-server application, I can't even properly formulate the problem and I don't know where to go and what to read? It's C++, it's Poco.
Thanks for any real advice :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-02-26
@firedragon

What is the problem on the same socket to "chew" different packets
Packet TYPE
0x01 - 00-FF
TYPE | LENGTH | BODY | CHECKSUM
In BODY you send the load, which is already parsed by the binary serializer, depending on the TYPE
AND calls the desired handler

R
res2001, 2020-02-26
@res2001

Before writing a network application, you would read a little about how everything works there, what difficulties there may be and how to get around them.
If you don't already know this, then a server on one listening socket can work with a bunch of clients. If you use TCP for the exchange, then for each connection with a new client, a new socket is created - a full-fledged socket. You can pass this socket to the handler process. Then you don't need a bunch of listening sockets.
You should not run a separate computing process for each client, if the calculations are resource-intensive, you will provide DDoS to your server with a couple of dozen clients, i.e. your server may simply die under load.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question