• Post Reply Bookmark Topic Watch Topic
  • New Topic

Several server sockets correspond to a single port?  RSS feed

 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

for evaluation purpose, I will need to run multiple instances of my server program on a single physical machine. I got an Address Already in Use (the port is already in use?) for starting the 2nd instance of my server program.

The line that throws the exception is:

ss = ssf.createServerSocket(port);

I just wonder whether there is a way to allow any number of my server programs running on a single machine?

Thank you very much
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not on the same port. But if you make the port configurable, you can run several servers on different ports.
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Do I have to? I really dont wanna modify the code developed by someone else.

I thought multiple sockets can be binded to a single physical port. Doesnt Java support this?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Java doesn't support this, because operating systems don't support this. What would it mean? When a request comes in, would the OS choose one process randomly? Round-robin? Based on availability? What?
[ July 11, 2006: Message edited by: Ernest Friedman-Hill ]
 
Lin Shen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That makes sense. Thanks very much for the advices.

I will put the problem on our wiki and ask the person who developed it to make the port configurable.

I am still not going to do it myself until the last minute.
 
Giovanni De Stefano
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure you REALLY want to run multiple istances of your server???

I suspect that you want to serve more than one client...this means that anytime a client connects to the server, the server creates a workerThread able to handle the communication with the client and then the server gets back to the waiting state (while the worker thread keeps serving the client)...and so on...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!