In TCPServer (Ruby) how can i get the IP/MAC from the client?
Posted
by a0rtega
on Stack Overflow
See other posts from Stack Overflow
or by a0rtega
Published on 2009-08-16T11:26:45Z
Indexed on
2010/04/20
5:23 UTC
Read the original article
Hit count: 313
Hi, i want to get the IP Address of the client in a TCPServer in Ruby. And (if it is possible) the MAC Address.
For example, a Time Server in Ruby, see the comment.
tcpserver = TCPServer.new("", 80)
if tcpserver
puts "Listening"
loop do
socket = tcpserver.accept
if socket
Thread.new do
puts "Connected from" + # HERE! How can i get the IP Address from the client?
socket.write(Time.now.to_s)
socket.close
end
end
end
end
Thank you very much!
© Stack Overflow or respective owner