What would be great if someone could fill in the blanks for me, or
point me to somewhere that does:
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
end
else
# UDP Client
client = UDPSocket.open
client.connect 'localhost', 12345
client.puts "Hello Server!"
# assert that we got "Hi there client!" back
end
On 7/6/05, Joe Van Dyk <joevandyk / gmail.com> 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
>