directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbet Reilly" <>
Subject Re: Detecting LDAP Port busy at start-up (Repost)
Date Wed, 07 Jun 2006 05:09:22 GMT
The usecase I have in mind is trying to detect if there is already an
OpenLDAP directory (C/C++) listening to the same port as A-DS, at the
time that A-DS is started.

In this situtation I have found that the OpenLDAP directory gets all
the traffic but there is no way to draw the user's attention to the

My understanding is that ServerSocket.bind() would detect the
situation, but because of the current implementation (based on nio)
the check is simply not being performed. I had in mind the Tomcat
behaviour, where it won't start up when it's port is busy (or is it
just the easier case of simply detecting when another Tomcat is using
the same port ?). I thought there was stuff in socket support to tell
if a particular socket was already being listened to, but then it's
been a long time since I last visited this low in the comms stack...

Quoting from  (which
is admittedly old) which I found in a google :
"When you create a ServerSocket object, it attempts to bind to the
port on the local host given by the port argument. If another server
socket is already listening to the port, then a, a subclass of, is thrown.
No more than one process or thread can listen to a particular port at
a time. This includes non-Java processes or threads. For example, if
there's already an HTTP server running on port 80, you won't be able
to bind to port 80."

The rest of my post was thinking out load about how to allow flexible
configuration of the "port busy" check, assuming that this check would
not required in all deployment situations (although it seems to me to
be the more sensible default).

View raw message