Joe Van Dyk
7/6/2005 8:44:00 PM
Related question:
If I need to send a message that's greater than 64KB back, is there
some standard Ruby way of doing so? (64KB seems to be the maximum
packet size)
On 7/6/05, Joe Van Dyk <joevandyk@gmail.com> wrote:
> Seems to work great, thanks!
>
> On 7/6/05, Guillaume Marcais <guslist@free.fr> wrote:
> > 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 <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
> > > >
> > >
> >
> >
> >
>