[Pharo-project] Server sockets, ephermal ports, and a Linux VM crash
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
2009/11/2 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
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 Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <siguctua@gmail.com> wrote:
2009/11/2 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
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 <johnmci@smalltalkconsulting.com> Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================
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: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John McIntosh Sent: Monday, November 02, 2009 9:43 PM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <siguctua@gmail.com<mailto:siguctua@gmail.com>> wrote: 2009/11/2 Schwab,Wilhelm K <bschwab@anest.ufl.edu<mailto:bschwab@anest.ufl.edu>>:
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 <johnmci@smalltalkconsulting.com<mailto:johnmci@smalltalkconsulting.com>> Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================
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 <bschwab@anest.ufl.edu>
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:* pharo-project-bounces@lists.gforge.inria.fr [mailto: pharo-project-bounces@lists.gforge.inria.fr] *On Behalf Of *John McIntosh *Sent:* Monday, November 02, 2009 9:43 PM *To:* Pharo-project@lists.gforge.inria.fr *Subject:* Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash
On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <siguctua@gmail.com> wrote:
2009/11/2 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
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 <johnmci@smalltalkconsulting.com> Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com ===========================================================================
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
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: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Mariano Martinez Peck Sent: Monday, November 02, 2009 10:25 PM To: Pharo-project@lists.gforge.inria.fr 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 <bschwab@anest.ufl.edu<mailto:bschwab@anest.ufl.edu>> 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: pharo-project-bounces@lists.gforge.inria.fr<mailto:pharo-project-bounces@lists.gforge.inria.fr> [mailto:pharo-project-bounces@lists.gforge.inria.fr<mailto:pharo-project-bounces@lists.gforge.inria.fr>] On Behalf Of John McIntosh Sent: Monday, November 02, 2009 9:43 PM To: Pharo-project@lists.gforge.inria.fr<mailto:Pharo-project@lists.gforge.inria.fr> Subject: Re: [Pharo-project] Server sockets, ephermal ports, and a Linux VM crash On Mon, Nov 2, 2009 at 5:52 PM, Igor Stasenko <siguctua@gmail.com<mailto:siguctua@gmail.com>> wrote: 2009/11/2 Schwab,Wilhelm K <bschwab@anest.ufl.edu<mailto:bschwab@anest.ufl.edu>>:
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 <johnmci@smalltalkconsulting.com<mailto:johnmci@smalltalkconsulting.com>> Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com =========================================================================== _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr<mailto:Pharo-project@lists.gforge.inria.fr> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
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 <johnmci@smalltalkconsulting.com> Twitter: squeaker68882 Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com = = = ========================================================================
participants (5)
-
Igor Stasenko -
John M McIntosh -
John McIntosh -
Mariano Martinez Peck -
Schwab,Wilhelm K