getsockname

basicsocket.getsockname => sockaddr
Instance Public methods

Returns the local address of the socket as a sockaddr string.

TCPServer.open("127.0.0.1", 15120) {|serv|
  p serv.getsockname #=> "\x02\x00;\x10\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"
}

If Addrinfo object is preferred over the binary string, use #local_address.

doc_ruby_on_rails
2015-03-31 00:53:25
Comments
Leave a Comment

Please login to continue.