S
S
Sparrow14882021-01-26 19:05:35
Computer networks
Sparrow1488, 2021-01-26 19:05:35

Is it right to allocate a whole port for a specific task on the server?

I hope I correctly painted my question
Evening, Habr! When writing a server, I asked this question: if I need to implement user authorization, sending data when requested (in my case, news blocks), as well as receiving and sending messages via chats, then for each task I need to allocate a separate port to receive, process and respond to certain requests? If not, and you can get by with only one port, then the question is: how can I filter the received data and by what criteria, so that, for example, when logging in, people receive an entry confirmation, and not a news block. Thanks in advance!
PS I work mainly with TCP, and client applications will be located on the desktop (if this somehow clarifies my question)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vasily Bannikov, 2021-01-26
@Sparrow1488

No. Allocating 100500 ports for each type of request is irrational.
We need some protocol over TCP - for example HTTP
If you want to implement your own - see how it works, for example.

G
Griboks, 2021-01-26
@Griboks

You receive a message of the form bytes=port+ip+load, where the load is obviously known to you and deserializable. And then it’s a matter of software, how and with what you will filter and parse bytes.
ps
Personally, it's more convenient for me to use protocols ala stateless X over JSON over UTF-8 over TCP.

D
d-stream, 2021-01-26
@d-stream

If you look at the question in terms of potential increases in load and expansion of functionality, then one port, on one host, will turn out to be a bottleneck. So you can look wider - services will spread over different hosts, etc. Or don't look at it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question