This implies having a sort of thread pool where each thread is waiting for connection on the corresponding port.
should I implement thread pool inside web app under Tomcat
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Ninad Kulkarni wrote:
Would you explain above statement briefly
Ulf Dittmer wrote:Why does the application need to listen on multiple ports? Tomcat (like all web and app servers) is multi-threaded, and can handle multiple clients connecting on the same port simultaneously.
Pavel Kazlou wrote:The problem is that the protocol used for communication between web application and device is plain TCP/IP. As long as I start communication with device using socket on port Y I must hold the connection till all the data is transmitted and socket is closed (and this may take some time as the user begins entering information only after the connection is established). It makes impossible for web application to open additional connection on port Y. So I need to use a range of ports to allow multiple devices to connect to my web application simultaneously.
Ulf Dittmer wrote:
Have a look at the ServerSocket class and the Networking chapter of the Sun Java Tutorial. It shows how to build a server that can accept multiple connection (which are simultaneously open and in use) on a single port. You will need to start multiple threads, but you don't need multiple ports.
Education won't help those who are proudly and willfully ignorant. They'll literally rather die before changing.
I knew I would regret that burrito. But this tiny ad has never caused regrets:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|