From: skaller <skaller@users.sourceforge.net>
To: Maurizio Colucci <maurizio.colucci@gmail.com>
Cc: caml-list <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Error binding socket
Date: Thu, 10 Nov 2005 00:29:38 +1100 [thread overview]
Message-ID: <1131542978.8562.43.camel@rosella> (raw)
In-Reply-To: <e919163f0511090433n77ab22acl@mail.gmail.com>
On Wed, 2005-11-09 at 13:33 +0100, Maurizio Colucci wrote:
> Hi there. For my free tennis game (http://freetennis.sf.net), I get an
> error binding the socket to a port. (Unix_error 50, "bind"). The error
> description is "address already in use".
>
> This error only happens the *second* time I start the program. It is
> as if the port had not been freed and were still in use. The system is
> GNU/Linux Ubuntu Breezy.
>
> However, if I wait about 1minute, or I start the program specifying a
> different port, the problem does not happen. It is as if Linux were
> freeing the port with a delay.
This is standard Unix behaviour.
use the setsockopt() function, these options may help
(from man 7 socket), I forget the Ocaml for this, but I know
it can be done because I had exactly the same problem myself once.
SO_REUSEADDR
Indicates that the rules used in validating addresses
supplied in a bind(2) call
should allow reuse of local addresses. For PF_INET
sockets this means that a
socket may bind, except when there is an active listening
socket bound to the
address. When the listening socket is bound to
INADDR_ANY with a specific port
then it is not possible to bind to this port for any local
address.
SO_LINGER
Sets or gets the SO_LINGER option. The argument is a
linger structure.
struct linger {
int l_onoff; /* linger active */
int l_linger; /* how many seconds to linger for */
};
When enabled, a close(2) or shutdown(2) will not return
until all queued mes‐
sages for the socket have been successfully sent or the
linger timeout has been
reached. Otherwise, the call returns immediately and the
closing is done in the
background. When the socket is closed as part of
exit(2), it always lingers in
the background.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2005-11-09 13:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-09 12:33 Maurizio Colucci
2005-11-09 12:55 ` [Caml-list] " Gerd Stolpmann
2005-11-09 13:02 ` Maurizio Colucci
2005-11-09 13:29 ` skaller [this message]
2005-11-09 14:36 ` Gerd Stolpmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1131542978.8562.43.camel@rosella \
--to=skaller@users.sourceforge.net \
--cc=caml-list@yquem.inria.fr \
--cc=maurizio.colucci@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox