TCPServer.new(port) creates a server that can service requests from localhost or remote machines.
But GServer.new(port) creates a server that can only service requests from localhost.
In looking at GServer's source, it calls TCPServer.new(@host,@port). @host defaults to DEFAULT_HOST which is 127.0.0.1.
The source for TCPServer.new says:
# TCPServer.new([hostname,] 开发者_运维问答port) => tcpserver
# Creates a new server socket bound to _port_.
# If _hostname_ is given, the socket is bound to it.
I would like to use GServer, but not bind to a certain host name. Is such a thing possible? Every example on the web uses only localhost.
It seems that if no host is specified to GServer, GServer should not specify a host to TCPServer.
Use 0.0.0.0
for your hostname to bind to all interfaces.
精彩评论