From: Bill McLean Date: 2010-04-27T00:11:49+09:00 Subject: Ruby networking: Errno::ECONNREFUSED: Connection refused - connect(2) on Ubuntu 9.1 ------=_NextPart_000_0018_01CAE531.438F1850 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit All, When using the Ruby networking library in two sample programs below I get the connect refused exception. To validate the code, I am running both the client and server code in separate terminal windows. The ip address given 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 my linux machine. Using ping I can explicitly ping the ip address without fail. Any help getting this working would be appreciated. Server.rb require 'socket' dts = TCPServer.new('localhost', 9900) loop do Thread.start(dts.accept) do |client| print(client, "is accepted\n") client.close end end Client.rb require 'socket' targetIp = "192.168.0.3" targetPort = 9900 begin server = TCPSocket.open(targetIp, targetPort) puts "Connected to Server" + targetIp + ":" + targetPort server.close rescue => ex puts "Connection to Server Failed: #{ex.class}: #{ex.message}" end Regards Bill McLean Technical Director ------=_NextPart_000_0018_01CAE531.438F1850--