• Post Reply Bookmark Topic Watch Topic
  • New Topic

ServerSocket - Close  RSS feed

 
Shiva Kumar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am created a ServerSocket at 7002(for ex). I am not closed that ServerSocket, now I want to create a new ServerSocket for the same port(7002). Normally it throughs "Bind Exception".
My requirement is I want to clear that port and I want to create a ServerSocket on that Port(7002).
Please Help.. Very Urgent.
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would u plz explain the actual problem again in more detail
Why r u not closing the previous socket.
& even if u dont want to close it
then just try some other port for new server sockets
u can have at most 2^16 ports in one system..
hope it will help U
 
Bert Heymans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a similar problem, maybe Shiva also wants to explicitly close a specific ServerSocket. When I make a ServerSocket on say, ... for instance port 7799 on my win2k (SP3, all updates) maschine and close the ServerSocket in the finally block in my code. Somehow the JVM still has port 7799 bound and I get a "java.net.BindException: Address in use: JVM_Bind". I think it is very stange because I also closed all clientsockets and the io-streams. And weirdest of all, when I compile and run on my Linux mashine the problem does not occur
If somebody knows the solution to this problem it would be greately appreciated!!!
 
Bert Heymans
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the problem, the ServerSocket was created inside a thread, after closing down the app the thread process still existed. In Eclipse I use the terminate button on the console window to stop everything, just interrupting the threads didn't work. When i find the solution to close it down properly I'll post it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!