开发者

Ruby's GServer only wants to work on localhost

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜