[TAG] Bind error
ny at youngman.org.uk
Sun Feb 5 14:14:53 MSK 2006
On Sunday 05 Feb 2006 08:59, roberto.bacenetti at lombardiacom.it wrote:
> Scrive Neil Youngman <neil.youngman at googlemail.com>:
> > On Friday 03 Feb 2006 11:44, roberto.bacenetti at lombardiacom.it wrote:
> > > I get an "Address already in use" when trying a bind in the following
> > > situation:
> > > a board with an ethernet and a ppp connection:
> > >
> > > when the board starts only the ethernet interface is on, and the
> > > program successfully binds to the specified port, and is able to accept
> > > connections; at some point the partner disconnects and a GPRS PPP
> > > connection is established, the
> > > old bind is already there and the program can accept a connection, when
> > > however the connection is closed any bind will fail, even after a long
> > time
> > > has elapsed.
Reading this again, it sounds as though you are trying to bind to the same
port, while the original program is running. If you have bound a socket it
will stay bound, even if it has accepted a connection, which has subsequently
I haven't got my reference books handy, but IIRC, you bind() and listen() on
one socket, then accept() creates a second socket. The far end disconnecting
closes the second socket. If you want to bind to the the original port again,
you have to close the first socket also.
> > > i wrote a test program which binds a socket to a specific interface and
> > > port: well with PPP on bind always fails.
Is PPP relevant here? Do you get the same failure with only the ethernet
> > > Can somone explain this ?
> > Do answers 2.7and 4.5 in the Unix Socket FAQ answer your question?
> > http://www.faqs.org/faqs/unix-faq/socket/
> > HTH
> > Neil Youngman
> It' not a matter of time delay, the error is persistent and I'm using
netstat -tulp should tell you which program is already listening on that
More information about the TAG