From: Guillaume Marcais Date: 2005-07-07T05:27:35+09:00 Subject: Re: UDPSocket question On Thu, 2005-07-07 at 05:21 +0900, Joe Van Dyk wrote: > What would be great if someone could fill in the blanks for me, or > point me to somewhere that does: Untested: > if fork > # UDP Server > server = UDPSocket.open > server.bind 'localhost', 12345 > while (message, sender = server.recvfrom(64)) > puts "We received: <#{message}> from #{sender[2]}" > > return_message = "Hi there client!" > # Send response message here server.send(return_message, 0, sender[2], sender[1]) > end > else > > # UDP Client > client = UDPSocket.open > client.connect 'localhost', 12345 > client.puts "Hello Server!" > # assert that we got "Hi there client!" back > end See UDPSocket#send in the Pickax. Guillaume. > On 7/6/05, Joe Van Dyk wrote: > > I'm having problems creating a UDP socket that listens for messages on > > a port and (sometimes) sends messages back to the original sender of > > the message. > > > > I can receive a message over the UDP socket fine, I'm just not sure > > about how to know where to send the message back, and how to properly > > send it back. > > > > Thanks, > > Joe > > >