Answer the question
In order to leave comments, you need to log in
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
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.
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question