🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #10347

Re: socket bind, close y bind otra vez

#10347
From: dcm
Date: Sun, 10 Mar 2002 12:00
30 lines
2106 bytes
On Thu, 07 Mar 2002 12:13:07 +0100, cusquejo wrote:

> Es algo llamado temporizador 2msl que te impide (por seguridad interna
> de unix) abrir un puerto que ha sido usado recientemente.
> 
> 
> se supone que esto no debiera dejarate hacerlo....
> 
> 

Mirar el c�digo que encontr�, para solucionar este problema.

Sometimes, you might notice, you try to rerun a server and
bind() fails, claiming "Address already in use."
What does that mean? Well, a bit a of socket that was connected is
still hanging around in the kernel, and it's hogging the port.  You can
either wait for it to clear (a minute or so), or add code to your
program allowing it to reuse the port, like this:

int yes=1;
//char yes='1'; // Solaris people use this
// lose the pesky "Address already in use" error message
    if (setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int)) == -1) {
        perror("setsockopt");
        exit(1);
    }

No lo he probado pero lo har�.

Gr�cias
Technical Details
Message-ID: <pan.2002.03.10.13.00.26.693460.1817@dedonde.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!jussieu.fr!news.rediris.es!news.cesca.es!not-for-mail
References: <pan.2002.02.28.17.37.59.905374.3821@dedonde.es> <a67hq9$3gv$1@cabezon.cpd.uva.es>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,a98bad80b63d6608
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-03-10 04:02:02 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!jussieu.fr!news.rediris.es!news.cesca.es!not-for-mail
From: dcm <dd@dedonde.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: socket bind, close y bind otra vez
Date: Sun, 10 Mar 2002 13:00:27 +0100
Organization: CESCA - Servidor de news de l'Anella Cientifica
Lines: 30
Message-ID: <pan.2002.03.10.13.00.26.693460.1817@dedonde.es>
References: <pan.2002.02.28.17.37.59.905374.3821@dedonde.es> <a67hq9$3gv$1@cabezon.cpd.uva.es>
NNTP-Posting-Host: mart.xtec.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: noucreus-atm.cesca.es 1015761720 3515 193.145.88.48 (10 Mar 2002 12:02:00 GMT)
X-Complaints-To: newsmanager@cesca.es
NNTP-Posting-Date: Sun, 10 Mar 2002 12:02:00 +0000 (UTC)
User-Agent: Pan/0.11.1 (Unix)
X-Comment-To: "cusquejo" <cusquejo@cusquejo.coj>