• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

port not reopening

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic