Get process that bind a port

Reuben D. Budiardja techlist at pathfinder.phys.utk.edu
Thu Dec 1 01:18:49 UTC 2005


On Wednesday 30 November 2005 14:14, Ezra Nugroho wrote:
> On Wed, 2005-11-30 at 13:34 -0500, Reuben D. Budiardja wrote:
> > On Wednesday 30 November 2005 12:54, STYMA, ROBERT E (ROBERT) wrote:
> > > > Hello,
> > > > I am playing around with writing a program to bind to socket
> > > > / port in my
> > > > machine. Often time, I got the message:
> > > > bind(): Address already in use
> > > >
<snip>
> > > Note that on various flavors unix, I have seen the "already in use"
> > > message for a short time after a program exits.  That is, start a
> > > program which listens on a certain port, exit the program, immediately
> > > restart the program.  A quick test says FC4 does not seem to do this.
> >
> > The reason I am asking is because I am seeing exactly this on FC 4.<snip>

> > | grep progname' shows nothing. Maybe I am doing something wrong, ie. the
> >
> > program does not release the port cleanly on exit or something like that
> > ? I'm not sure...
>
> Is this an RPC client-server program?
> If it is, it's done intentionally so that any messages that may still
> float around have a destination to rest in peace.

No RPC (if I understand what that means correctly), just 'regular' socket 
programming.

> Use "select()" socket utility.
> It may mean a little extra programming, but it is really rewarding.

Not sure how select() would help here. In this case the "server" side just do 
really simple stuff, basically read and write to socket descriptor. It could 
be that when server is interupted, there is still I/O that makes it not 
immediately release the port. Are you saying using select() to clean up ?

RDB




More information about the fedora-list mailing list