When using the Ruby networking library in two sample programs below I
the connect refused exception. To validate the code, I am running both
client and server code in separate terminal windows. The ip address
is the address that has been assigned to the eth0 device.
The client fails to connect to the server. However if I change the ip
address to localhost or 127.0.0.1 then the connection is made.
It may not have anything to do with ruby, but with the configuration of
Using ping I can explicitly ping the ip address without fail.
Any help getting this working would be appreciated.
dts = TCPServer.new(‘localhost’, 9900)
Thread.start(dts.accept) do |client|
print(client, "is accepted\n") client.close
targetIp = “192.168.0.3”
targetPort = 9900
server = TCPSocket.open(targetIp, targetPort)
puts "Connected to Server" + targetIp + ":" + targetPort server.close
rescue => ex
puts "Connection to Server Failed: