Reputation: 6089
I want to write an application in Java which will receive three requests at the same time continuously, then in the figure below which way is better and why to write the code or is there any other way better then these two? Thanks
Upvotes: 1
Views: 53
Reputation: 21923
If for each Request the processing of the request is same, then it is better that you use the same port with multiple threads to process it.
The usual practice is that for each functionality to have a different port in a system. For example FTP - Not Secured, SFTP - Secured.
Upvotes: 2
Reputation: 311050
It hardly makes any difference. All the activity with the ServerSocket
itself is concerned with accepting connections and starting threads. There's no need for three ServerSockets
and three threads to do this. In any case as they will all be listening to different ports, which one gets used is determined by the client, so it's pretty pointless: all clients could end up using only one of the ServerSockets.
Upvotes: 3