Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

port not reopening  RSS feed

 
Nick George
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the following code, it seems to me that a ServerSocket on port 3333 ought to be created, then it should wait for a connection, and then it should set up a Dialogue (extends Thread) with that socket. Then, it should reset itself. HOWEVER, it appears to be giving a number of Adress Already In Use Exceptions before reseting, which says to me that the port is taking some time before closing and reopening. it seems that the time it takes increases rapidly, until eventually it fails altogether to reopen. Any ideas on how to make it immediatly reopen?
 
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
Well, let's see. I don't see where you close the ServerSocket ever, so I don't know why you think you need to create a new one for each connection. Only one ServerSocket can be open for a given port (on an entire machine, not just in one program.) The while loop will very rapidly cycle back to the beginning and try again, failing every time.
I think what you mean to do is this:

This will accept up to 30 connections, and then stop listening.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!