Multiple images listening on same TCP port

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

Multiple images listening on same TCP port

Adrian Lienhard
 
Hi,

On the Mac VM, when starting a second image with the same VM as an  
already running image, the second image opens the same TCP ports as  
the first image.

It is easy to see this. Start image A and do:

s := Socket newTCP.
s listenOn: 7777.

as expected:

lsof -i | grep Squeak
Squeak    1747 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt (LISTEN)

Now, start image B (PID 1752).

lsof -i | grep Squeak
Squeak    1747 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt (LISTEN)
Squeak    1752 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt (LISTEN)

It will also listen on port 7777...

Is this a known limitation?

VM: 3.8.20beta1U
Image: any (tested with Squeak 3.9 and 3.10)

Cheers,
Adrian
___________________
http://www.adrian-lienhard.ch/

Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

johnmci
 
Ok, I assume you did
> s := Socket newTCP.
> s listenOn: 7777.

in both images.

Yes Unix will allow that, this is not a squeak vm issue,

Check the socket options  to see if any apply to your needs of  
preventing two apps from acquiring the same socket
at the same time.


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
   { (char *)0, 0, 0 }
};



On 9-Jun-09, at 9:47 AM, Adrian Lienhard wrote:

> Hi,
>
> On the Mac VM, when starting a second image with the same VM as an  
> already running image, the second image opens the same TCP ports as  
> the first image.
>
> It is easy to see this. Start image A and do:
>
> s := Socket newTCP.
> s listenOn: 7777.
>
> as expected:
>
> lsof -i | grep Squeak
> Squeak    1747 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt  
> (LISTEN)
>
> Now, start image B (PID 1752).
>
> lsof -i | grep Squeak
> Squeak    1747 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt  
> (LISTEN)
> Squeak    1752 adrian    9u  IPv4 0x9dafa68      0t0  TCP *:cbt  
> (LISTEN)
>
> It will also listen on port 7777...
>
> Is this a known limitation?
>
> VM: 3.8.20beta1U
> Image: any (tested with Squeak 3.9 and 3.10)
>
> Cheers,
> Adrian
> ___________________
> http://www.adrian-lienhard.ch/
>

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




Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

Adrian Lienhard
 
Hi John,

On Jun 9, 2009, at 18:53 , John M McIntosh wrote:

> Ok, I assume you did
>> s := Socket newTCP.
>> s listenOn: 7777.
>
> in both images.

No. Just in the first image.

Adrian
Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

Andreas.Raab
 
Adrian Lienhard wrote:
> On Jun 9, 2009, at 18:53 , John M McIntosh wrote:
>
>> Ok, I assume you did
>>> s := Socket newTCP.
>>> s listenOn: 7777.
>>
>> in both images.
>
> No. Just in the first image.

I think it's more likely that you've got some code loaded that launches
a listener automatically. Check Socket allInstances in the second image
to see if there are any sockets.

Cheers,
   - Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

Adrian Lienhard
 

On Jun 9, 2009, at 23:47 , Andreas Raab wrote:

> Adrian Lienhard wrote:
>> On Jun 9, 2009, at 18:53 , John M McIntosh wrote:
>>> Ok, I assume you did
>>>> s := Socket newTCP.
>>>> s listenOn: 7777.
>>>
>>> in both images.
>> No. Just in the first image.
>
> I think it's more likely that you've got some code loaded that  
> launches a listener automatically. Check Socket allInstances in the  
> second image to see if there are any sockets.

That's what I thought first too. But no, it happens also in vanilla  
images. There exist no socket instances in the second image.

Adrian
Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

johnmci
In reply to this post by Adrian Lienhard
 
How are you starting the 2nd image, what is the procedure you do,  
double click an image, drag an image to the dock, use the cmd line, etc?

On 9-Jun-09, at 9:47 AM, Adrian Lienhard wrote:

> Hi,
>
> On the Mac VM, when starting a second image with the same VM as an  
> already running image, the second image opens the same TCP ports as  
> the first image.

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




Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

Adrian Lienhard
 
Either by dragging the image on the icon of the already running VM in  
the dock, or by double clicking on the image.

Can somebody reproduce this or am I seeing ghosts?

Adrian

On Jun 10, 2009, at 08:48 , John M McIntosh wrote:

> How are you starting the 2nd image, what is the procedure you do,  
> double click an image, drag an image to the dock, use the cmd line,  
> etc?
>
> On 9-Jun-09, at 9:47 AM, Adrian Lienhard wrote:
>
>> Hi,
>>
>> On the Mac VM, when starting a second image with the same VM as an  
>> already running image, the second image opens the same TCP ports as  
>> the first image.
>
> --
> =
> =
> =
> =
> =
> ======================================================================
> John M. McIntosh <[hidden email]>   Twitter:  
> squeaker68882
> Corporate Smalltalk Consulting Ltd.  http://
> www.smalltalkconsulting.com
> =
> =
> =
> =
> =
> ======================================================================
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

Andreas.Raab
 
Adrian Lienhard wrote:
> Either by dragging the image on the icon of the already running VM in
> the dock, or by double clicking on the image.
>
> Can somebody reproduce this or am I seeing ghosts?

Well, there are strange things on the Mac in some ways. I don't recall
but didn't John have to do special black magic to make this work at all
(the Mac with its resistance to launching another instance of an app if
one is running already)? Perhaps it's the side effect of doing a fork()
that clones that socket handle implicitly?

Cheers,
   - Andreas
Reply | Threaded
Open this post in threaded view
|

Re: Multiple images listening on same TCP port

johnmci
 
Oh yes I'm thinking it's the fork, I have to check where/how because  
the logic is *really old* and uses AppleScript to do the dirty work  
versus execve

Adrian gets bonus points for finding this since it's a really old mac  
vm *feature*...

On 10-Jun-09, at 1:01 AM, Andreas Raab wrote:

> Adrian Lienhard wrote:
>> Either by dragging the image on the icon of the already running VM  
>> in the dock, or by double clicking on the image.
>> Can somebody reproduce this or am I seeing ghosts?
>
> Well, there are strange things on the Mac in some ways. I don't  
> recall but didn't John have to do special black magic to make this  
> work at all (the Mac with its resistance to launching another  
> instance of an app if one is running already)? Perhaps it's the side  
> effect of doing a fork() that clones that socket handle implicitly?
>
> Cheers,
>  - Andreas

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