Server sockets, ephermal ports, and a Linux VM crash

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

Server sockets, ephermal ports, and a Linux VM crash

Schwab,Wilhelm K
Hello all,

Is there a preferred way to create TCP servers?  KomServices and ConnectionQueue are options; there has been some discussion of the future of KomServices???

A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.  I have used that on Windows and it seems to work on Linux.  TcpService does a lot to hide its listening socket; some small changes would allow it to use ephemeral ports.  Any interest?  They seem to work now, but there is no clean way to query the port that is ultimately chosen; the goal is to be able to so allocate a port and then send it to the other side for out of band communications.

Perhaps related to my toying with port numbers (but I doubt that), I have had my older image crash a few times today.  I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.

Bill




_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

Igor Stasenko
2009/11/2 Schwab,Wilhelm K <[hidden email]>:
> Hello all,
>
> Is there a preferred way to create TCP servers?  KomServices and ConnectionQueue are options; there has been some discussion of the future of KomServices???
>
> A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.  I have used that on Windows and it seems to work on Linux.  TcpService does a lot to hide its listening socket; some small changes would allow it to use ephemeral ports.  Any interest?  They seem to work now, but there is no clean way to query the port that is ultimately chosen; the goal is to be able to so allocate a port and then send it to the other side for out of band communications.
>
Never tried it.
A #localPort should answer the port number to which a given socket is bound.
There is also #getOption: , but i'm not sure if it works similar on
all platforms.

> Perhaps related to my toying with port numbers (but I doubt that), I have had my older image crash a few times today.  I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.
>
> Bill
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

johnmci


On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <[hidden email]> wrote:
2009/11/2 Schwab,Wilhelm K <[hidden email]>:

> A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.

OS-X assigns you the range 49152-65535
 
 As for the getOption, the values for the key and the results is platform specific, and likely operating system version specific too. However for platforms that use BSD sockets, ala (Unix/Linux/OS-X) then the keys are in this table. Obviously if you fiddle with them then you know what you are doing? 


  { "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


 I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.
>
> Bill

More details required about the crashes? Whatever crashes mean.  



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



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

Schwab,Wilhelm K
John,
 
By crash, I mean pretty much the standard thing: one instant, Pharo is running, click something on the inspector, and suddenly Pharo is gone.  Not good.
 
Bill

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of John McIntosh
Sent: Monday, November 02, 2009 9:43 PM
To: [hidden email]
Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash



On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <[hidden email]> wrote:
2009/11/2 Schwab,Wilhelm K <[hidden email]>:

> A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.

OS-X assigns you the range 49152-65535
 
 As for the getOption, the values for the key and the results is platform specific, and likely operating system version specific too. However for platforms that use BSD sockets, ala (Unix/Linux/OS-X) then the keys are in this table. Obviously if you fiddle with them then you know what you are doing? 


  { "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


 I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.
>
> Bill

More details required about the crashes? Whatever crashes mean.  



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



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

Mariano Martinez Peck
Bill: As always, it would help if you can give us/them more information. For example, running Pharo from command line and send the output of the command line. Or the PharoDebug.log or whatever other thing that may help.

Best

mariano

2009/11/3 Schwab,Wilhelm K <[hidden email]>
John,
 
By crash, I mean pretty much the standard thing: one instant, Pharo is running, click something on the inspector, and suddenly Pharo is gone.  Not good.
 
Bill

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of John McIntosh
Sent: Monday, November 02, 2009 9:43 PM
To: [hidden email]
Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash



On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <[hidden email]> wrote:
2009/11/2 Schwab,Wilhelm K <[hidden email]>:

> A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.

OS-X assigns you the range 49152-65535
 
 As for the getOption, the values for the key and the results is platform specific, and likely operating system version specific too. However for platforms that use BSD sockets, ala (Unix/Linux/OS-X) then the keys are in this table. Obviously if you fiddle with them then you know what you are doing? 


  { "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


 I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.
>
> Bill

More details required about the crashes? Whatever crashes mean.  



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



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

Schwab,Wilhelm K
Mariano,
Understood.  I have not had time to run it down, but I am not being a complete slug today (not that you implied I was being such).  I added to my stream protocol, wrote a nice test of in-image socket server and client, and am now tweaking my "load script" to look for code that I wrote and is not properly packaged.  My image is ancient, and I don't know when Stef might make good on his threat to hunt us down for that :)
 
Bill
 

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Mariano Martinez Peck
Sent: Monday, November 02, 2009 10:25 PM
To: [hidden email]
Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash

Bill: As always, it would help if you can give us/them more information. For example, running Pharo from command line and send the output of the command line. Or the PharoDebug.log or whatever other thing that may help.

Best

mariano

2009/11/3 Schwab,Wilhelm K <[hidden email]>
John,
 
By crash, I mean pretty much the standard thing: one instant, Pharo is running, click something on the inspector, and suddenly Pharo is gone.  Not good.
 
Bill

 


From: [hidden email] [mailto:[hidden email]] On Behalf Of John McIntosh
Sent: Monday, November 02, 2009 9:43 PM
To: [hidden email]
Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash



On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <[hidden email]> wrote:
2009/11/2 Schwab,Wilhelm K <[hidden email]>:

> A nice trick is to use "ephmeral" ports, which is a fancy way of saying to pass zero for the listening port and let the OS assign a port.

OS-X assigns you the range 49152-65535
 
 As for the getOption, the values for the key and the results is platform specific, and likely operating system version specific too. However for platforms that use BSD sockets, ala (Unix/Linux/OS-X) then the keys are in this table. Obviously if you fiddle with them then you know what you are doing? 


  { "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


 I created a TcpService on port zero, the listening socket gets a port and all seems reasonably well until I later inspect a few aspects of the TcpService, at which point the vm crashes.
>
> Bill

More details required about the crashes? Whatever crashes mean.  



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



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Server sockets, ephermal ports, and a Linux VM crash

johnmci
In reply to this post by Schwab,Wilhelm K
A simple example, and a mantis/pharo bug report/ would be helpful.

In looking at the code the printOn: for example invokes  
primitiveSocketConnectionStatus
and that C code seems fairly paranoid about it's use of a private  
pointer that points to the supposed operating system data.
However without an example it's hard to finger what is at fault.

Also you could run the VM under gnu debug then at the crash you can  
invoke in the Gnu debugger cmd line
call (int) printAllStacks()

That will at least indicate the squeak Process stacks to give a  
clearer example of how the crash occurs.


On 2009-11-02, at 7:22 PM, Schwab,Wilhelm K wrote:

> John,
>
> By crash, I mean pretty much the standard thing: one instant, Pharo  
> is running, click something on the inspector, and suddenly Pharo is  
> gone.  Not good.
>
> Bill
>
>

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





_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project