Hi All,
I’m using Ruby 1.6.6 (Andy’s version) on Win NT 4 SP5 or 6, and Win XP.
I wrote a simple TCP server with the following accept loop:
def accept_loop
session = nil
req = ''
while(session = @server.accept)
p Socket.getnameinfo(session.getpeername)
req = session.read(200)
verify_request(req)
session.write(@reply)
session.close
end
end
The ‘p’ statement is there because I want to get the foreign/remote ip and
port
of the socket connection. But getnameinfo(getpeername) does not work for me.
I
get the following error after a connection is made:
-----8<--------8<-----------------------------------------------
encotoneserver.rb:24:in getnameinfo': getnameinfo: address family for hostname not supported. (SocketError) from encotoneserver.rb:24:in
accept_loop’
from encotoneserver.rb:40
-----8<--------8<-----------------------------------------------
What is the right way to get the foreign ip and port?
Barry