[squeak-dev] Closing a socket for port re-use - dumb question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Closing a socket for port re-use - dumb question

Schwab,Wilhelm K
Hello all,

Slightly OT, except that I am asking for the potential benefit of
Squeak.  Several years ago, I had problems with closing a server socket
such that same service could be restarted on the same port.  There must
be a correct way to do this (too many products do it successfully for it
to be a problem), but at the time I was told that ephemeral
("dynamically allocated") ports were the best solution.  I got it
working, but have regretted it due to fire walls and other criteria.

Can anyone point me to what I might have been doing wrong, and/or an
example of how to do it correctly?  Of course, stress testing start/stop
of a Seaside server could be a nice place to start to verify that it is
not a problem.  However, I would ideally like to understand the problem
so I won't walk into it again.  Perhaps it was just a Windows bug???

Thanks,

Bill




Wilhelm K. Schwab, Ph.D.
University of Florida
Department of Anesthesiology
PO Box 100254
Gainesville, FL 32610-0254

Email: [hidden email]
Tel: (352) 846-1285
FAX: (352) 392-7029


Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: Closing a socket for port re-use - dumb question

Andreas.Raab
Bill Schwab wrote:
> Can anyone point me to what I might have been doing wrong, and/or an
> example of how to do it correctly?

Not unless you give some actual information like: What have you tried
already? Which port are you trying to run on? What happens when you
actually restart the server? Etc. As for an example, try this:

[true] whileTrue:[
        server := Socket newTCP.
        server listenOn: 1234 backlogSize: 4.
        Transcript cr; show: server.
        client := Socket newTCP.
        client connectTo: NetNameResolver localHostAddress port: 1234.
        Transcript cr; show: client.
        socket := server accept.
        Transcript cr; show: socket.
        server destroy.
        client destroy.
        socket destroy.
].

I can leave this loop running forever so obviously there isn't any
intrinsic problem with running servers on the same port.

Cheers,
   - Andreas


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Closing a socket for port re-use - dumb question

Randal L. Schwartz
In reply to this post by Schwab,Wilhelm K
Not sure in the windows world, but by design, sockets closed are held  
closed for two minutes in case late packets arrive. If you don't care  
about that you can set "socket reuse" on the socket before you close it.

Pardon me if this is brief, but I'm sending this from my iPhone!

On Feb 29, 2008, at 10:10 AM, "Bill Schwab" <[hidden email]>  
wrote:

> Hello all,
>
> Slightly OT, except that I am asking for the potential benefit of
> Squeak.  Several years ago, I had problems with closing a server  
> socket
> such that same service could be restarted on the same port.  There  
> must
> be a correct way to do this (too many products do it successfully  
> for it
> to be a problem), but at the time I was told that ephemeral
> ("dynamically allocated") ports were the best solution.  I got it
> working, but have regretted it due to fire walls and other criteria.
>
> Can anyone point me to what I might have been doing wrong, and/or an
> example of how to do it correctly?  Of course, stress testing start/
> stop
> of a Seaside server could be a nice place to start to verify that it  
> is
> not a problem.  However, I would ideally like to understand the  
> problem
> so I won't walk into it again.  Perhaps it was just a Windows bug???
>
> Thanks,
>
> Bill
>
>
>
>
> Wilhelm K. Schwab, Ph.D.
> University of Florida
> Department of Anesthesiology
> PO Box 100254
> Gainesville, FL 32610-0254
>
> Email: [hidden email]
> Tel: (352) 846-1285
> FAX: (352) 392-7029
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Closing a socket for port re-use - dumb question

Schwab,Wilhelm K
In reply to this post by Schwab,Wilhelm K
Andreas, Randal,

=====================================
Randal wrote:

Not sure in the windows world, but by design, sockets closed are held
closed for two minutes in case late packets arrive. If you don't care
about that you can set "socket reuse" on the socket before you close it.
*---------------------------------------------------------------------

By that, do you mean something like "socket setOption: 'SO_REUSEADDR' value: true." that I just found in the image?  There is also an SO_REUSEPORT which is probably more what I want.  I will read up on them shortly.

Of course, there is Andreas' example which appears to suggest that there is no problem.  All I remember is that I had problems, got conflicting advice, and ultimately found ephemeral ports solved my immediate (at the time) problem at the expense of some work and firewall hassles.  I suspect the reuse options are the answer.

Thanks for the pointers!!!

Bill




Wilhelm K. Schwab, Ph.D.
University of Florida
Department of Anesthesiology
PO Box 100254
Gainesville, FL 32610-0254

Email: [hidden email]
Tel: (352) 846-1285
FAX: (352) 392-7029



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Closing a socket for port re-use - dumb question

johnmci
The unix like systems support these items, subject of much debate a  
few years back.

static socketOption socketOptions[]= {
   { "SO_DEBUG", SOL_SOCKET, SO_DEBUG },
   { "SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR },
   { "SO_DONTROUTE", SOL_SOCKET, SO_DONTROUTE },
   { "SO_BROADCAST", SOL_SOCKET, SO_BROADCAST },
   { "SO_SNDBUF", SOL_SOCKET, SO_SNDBUF },
   { "SO_RCVBUF", SOL_SOCKET, SO_RCVBUF },
   { "SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE },
   { "SO_OOBINLINE", SOL_SOCKET, SO_OOBINLINE },
   { "SO_LINGER", SOL_SOCKET, SO_LINGER },
   { "IP_TTL", SOL_IP, IP_TTL },
   { "IP_HDRINCL", SOL_IP, IP_HDRINCL },
   { "IP_MULTICAST_IF", SOL_IP, IP_MULTICAST_IF },
   { "IP_MULTICAST_TTL", SOL_IP, IP_MULTICAST_TTL },
   { "IP_MULTICAST_LOOP", SOL_IP, IP_MULTICAST_LOOP },
#ifdef IP_ADD_MEMBERSHIP
   { "IP_ADD_MEMBERSHIP", SOL_IP, IP_ADD_MEMBERSHIP },
   { "IP_DROP_MEMBERSHIP", SOL_IP, IP_DROP_MEMBERSHIP },
#endif
   { "TCP_MAXSEG", SOL_TCP, TCP_MAXSEG },
   { "TCP_NODELAY", SOL_TCP, TCP_NODELAY },
#ifdef SO_REUSEPORT
   { "SO_REUSEPORT", SOL_SOCKET, SO_REUSEPORT },
#endif


On Feb 29, 2008, at 4:38 PM, Bill Schwab wrote:

> Andreas, Randal,
>
> =====================================
> Randal wrote:
>
> Not sure in the windows world, but by design, sockets closed are held
> closed for two minutes in case late packets arrive. If you don't care
> about that you can set "socket reuse" on the socket before you close  
> it.
> *---------------------------------------------------------------------
>
> By that, do you mean something like "socket setOption:  
> 'SO_REUSEADDR' value: true." that I just found in the image?  There  
> is also an SO_REUSEPORT which is probably more what I want.  I will  
> read up on them shortly.
>
> Of course, there is Andreas' example which appears to suggest that  
> there is no problem.  All I remember is that I had problems, got  
> conflicting advice, and ultimately found ephemeral ports solved my  
> immediate (at the time) problem at the expense of some work and  
> firewall hassles.  I suspect the reuse options are the answer.
>
> Thanks for the pointers!!!
>
> Bill
>
>
>
>
> Wilhelm K. Schwab, Ph.D.
> University of Florida
> Department of Anesthesiology
> PO Box 100254
> Gainesville, FL 32610-0254
>
> Email: [hidden email]
> Tel: (352) 846-1285
> FAX: (352) 392-7029
>
>
>

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================