[zeromq-dev] Any way to flush or clear or manage ports?

Scott Asher scottpriceasher at gmail.com
Sun Sep 4 14:25:19 CEST 2011


Hi guys,

While I am not a real expert, my understanding is this:

Windows does not follow BSD semantics with respect to SO_REUSEADDR.
 Specifically, SO_REUSEADDR allows multiple processes to bind to the same
port on a single interface, resulting in indeterministic behavior with
respect to who gets what packets.  Why MSFT made this design decision, I am
not sure, but SO_EXCLUSIVEADDRUSE is supposed to result in behavior more
similar to BSD-style, but in practice it doesn't work out that way.  I don't
think there is a perfect solution here.  My suggestion is that we not change
the Windows implementation back to use SO_REUSEADDR because that will just
make everyone's life hell with respect to debugging (at least you KNOW why
code that can't bind to a port is failing).  ONe additional suggestion for
Windows users is to tweak the TcpTimedWaitDelay registry setting found at:

*HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters*

I think you can set it as low as 30s and the default is 120s, so 30s will be
much less annoying if you are constantly creating/deleting listening
sockets.

Scott

On Sun, Sep 4, 2011 at 6:00 AM, <zeromq-dev-request at lists.zeromq.org> wrote:

> Send zeromq-dev mailing list submissions to
>        zeromq-dev at lists.zeromq.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> or, via email, send a message with subject or body 'help' to
>        zeromq-dev-request at lists.zeromq.org
>
> You can reach the person managing the list at
>        zeromq-dev-owner at lists.zeromq.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of zeromq-dev digest..."
>
>
> Today's Topics:
>
>   1. Re: Any way to flush or clear or manage ports? (Martin Sustrik)
>   2. Re: Any way to flush or clear or manage ports? (Elliot Saba)
>   3. Re: Any way to flush or clear or manage ports? (Martin Sustrik)
>   4. Re: Option for choosing polling system (Martin Sustrik)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 04 Sep 2011 07:33:09 +0200
> From: Martin Sustrik <sustrik at 250bpm.com>
> Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
> To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
> Cc: Marc Ilgen <marc at westofpluto.com>
> Message-ID: <4E630D95.3060100 at 250bpm.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 09/03/2011 07:18 PM, Marc Ilgen wrote:
> > I'm using Windows Vista, and using version 2.1.7 of 0MQ. I'd like to get
> a
> > solution that clears ports on any modern Windows system (Win7, Vista, XP)
>
> Two thoughts:
>
> 1. Aren't you running the listining process in the debugger? In theory,
> when it fails under debugger it may not correctly release all listening
> ports as the debugging process doesn't really exit.
>
> 2. It may be some windows-specific behaviour. In any case try checking
> which process uses the port (eg. "netstat -o -n -a | findstr :80" and
> look up the process ID in the task manager).
>
> Martin
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 3 Sep 2011 23:55:25 -0700
> From: Elliot Saba <staticfloat at gmail.com>
> Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
> To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
> Cc: Marc Ilgen <marc at westofpluto.com>
> Message-ID:
>        <CAGGi21Zdf2OvDydXqHm9yUWo3zGC01XN4kAhBZn3UusAsfA7Ow at mail.gmail.com
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello, Marc, in addition, I suggest you read up on the SO_REUSEADDR (On
> linux, there is also a SO_REUSEPORT option, but SO_REUSEADDR should do the
> same thing on windows) socket option, and if that looks like your problem,
> maybe try modifying the sources to use that option when creating a socket.
> -E
>
> On Sat, Sep 3, 2011 at 10:33 PM, Martin Sustrik <sustrik at 250bpm.com>
> wrote:
>
> > On 09/03/2011 07:18 PM, Marc Ilgen wrote:
> > > I'm using Windows Vista, and using version 2.1.7 of 0MQ. I'd like to
> get
> > a
> > > solution that clears ports on any modern Windows system (Win7, Vista,
> XP)
> >
> > Two thoughts:
> >
> > 1. Aren't you running the listining process in the debugger? In theory,
> > when it fails under debugger it may not correctly release all listening
> > ports as the debugging process doesn't really exit.
> >
> > 2. It may be some windows-specific behaviour. In any case try checking
> > which process uses the port (eg. "netstat -o -n -a | findstr :80" and
> > look up the process ID in the task manager).
> >
> > Martin
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110903/85fd102d/attachment.html
>
> ------------------------------
>
> Message: 3
> Date: Sun, 04 Sep 2011 09:52:37 +0200
> From: Martin Sustrik <sustrik at 250bpm.com>
> Subject: Re: [zeromq-dev] Any way to flush or clear or manage ports?
> To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
> Cc: Marc Ilgen <marc at westofpluto.com>, Elliot Saba
>        <staticfloat at gmail.com>
> Message-ID: <4E632E45.50805 at 250bpm.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 09/04/2011 08:55 AM, Elliot Saba wrote:
> > Hello, Marc, in addition, I suggest you read up on the SO_REUSEADDR (On
> > linux, there is also a SO_REUSEPORT option, but SO_REUSEADDR should do
> > the same thing on windows) socket option, and if that looks like your
> > problem, maybe try modifying the sources to use that option when
> > creating a socket.
>
> The following code is responsible for tuning the listening socket:
>
>     //  Allow reusing of the address.
>     int flag = 1;
> #ifdef ZMQ_HAVE_WINDOWS
>     rc = setsockopt (s, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
>         (const char*) &flag, sizeof (int));
>     wsa_assert (rc != SOCKET_ERROR);
> #else
>     rc = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof (int));
>     errno_assert (rc == 0);
> #endif
>
>
> I guess the WINDOWS part may be wrong.
>
> Can anyone with win experience comment?
>
> Martin
>
>
> ------------------------------
>
> Message: 4
> Date: Sun, 04 Sep 2011 10:29:05 +0200
> From: Martin Sustrik <sustrik at 250bpm.com>
> Subject: Re: [zeromq-dev] Option for choosing polling system
> To: ZeroMQ development list <zeromq-dev at lists.zeromq.org>
> Cc: Mikko Koppanen <mikko.koppanen at gmail.com>
> Message-ID: <4E6336D1.6060604 at 250bpm.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 09/03/2011 05:16 PM, Mikko Koppanen wrote:
> > Added option to choose internal polling system
>
> Applied to the trunk.
>
> Thanks!
> Martin
>
>
> ------------------------------
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
> End of zeromq-dev Digest, Vol 45, Issue 12
> ******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110904/0b6c5521/attachment.htm>


More information about the zeromq-dev mailing list