Joel VanderWerf
6/10/2008 10:51:00 PM
Leslie Viljoen wrote:
> Below is my guess that doesn't work - I get connection refused when
> trying to connect to the port.
[~/tmp] cat serv.rb
require 'socket'
class UdpServer
def initialize(ip, port)
socket = UDPSocket.new
socket.bind(ip, port)
loop do
a = IO.select([socket], nil, nil, 5)
if a
p socket.recvfrom(1000)
end
end
end
end
s = UdpServer.new("0.0.0.0", 7778)
[~/tmp] cat clnt.rb
require 'socket'
s = UDPSocket.new
s.connect("0.0.0.0", 7778)
s.send("foo bar", 0)
[~/tmp] ruby serv.rb
["foo bar", ["AF_INET", 35088, "localhost", "127.0.0.1"]]
["foo bar", ["AF_INET", 35088, "localhost", "127.0.0.1"]]
(this shows output from running clnt.rb twice)
Does this still cause connection refused? Is it a firewall issue?
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407