From: Hamid Rasoulian Date: 2006-06-20T05:22:50+09:00 Subject: How to get the response from a UDP socket. ------_=_NextPart_001_01C693DE.20E09879 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =20 =20 Problem. I set up a UDP socket connection. I send a message to the socket, and the destination device receives the message correctly and act upon it, so far so good, but the destination device would send a message back to the host and I do not know how to capture that message and print the message.=20 =20 Here is what I do, the local port is $port1 and $IP1 and the destination assume to be $port2 and $IP2 I do the following: =20 require 'socket' $port1 =3D 5000 $IP1 =3D '10.15.0.21' =20 $port2 =3D 15000 $IP2 =3D '10.15.0.66' =20 sock =3D UDPSocket.open sock.bind($IP1 , $port1) sock.connect($IP2 , $port2) =20 =20 server_thread =3D Thread.start do server =3D UDPSocket.open server.bind(nil, $port1) 2.times { p server.recvfrom(64) } end =20 =20 # now I send the message to device. sock.send (" my UDP message", 0) =20 # and immediately I enter this command server_thread.join =20 But nothing happens. And no receiving message is being printed out, while I am sure the device has sent some message back. I just do not understand the receiving part of it. Can any body help me with it. =20 =20 =20 ------_=_NextPart_001_01C693DE.20E09879--