Answer the question
In order to leave comments, you need to log in
What is better to use multithreading or non-blocking input / output for the messenger?
What is better to use multithreading or NIO for a messenger.
Answer the question
In order to leave comments, you need to log in
It is better to use the technology that is more suitable for solving specific problems in certain conditions. They are not mentioned in your question.
It is wasteful to create a thread for each request, use asynchrony.
The architecture is something like this:
1. define bindings to ip
2. in a loop create a listener for each ip (or bind to 0.0.0.0)
3. create an array of input buffers for each listener
4. add the connection to the buffer when connecting
5. read data and what then do with them
Look at this example, there are wrappers in Jave, but the essence is the same
https://www.ibm.com/support/knowledgecenter/ssw_ib...
Multithreading is not about connections, but threads processing each connection.
NIO is network communication.
You have to use both!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question