From: Francis Cianfrocca Date: 2006-06-20T07:14:17+09:00 Subject: Re: How to get the response from a UDP socket. ------=_Part_4676_3703969.1150755250673 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Try running your server process without threads. You may find out that sock.send is throwing an exception that you can't see because it quietly kills your thread. Don't use connections with UDP. They don't make sense in the first place. On 6/19/06, Hamid Rasoulian wrote: > > > > > > 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. > > > > 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: > > > > require 'socket' > > $port1 = 5000 > > $IP1 = '10.15.0.21' > > > > $port2 = 15000 > > $IP2 = '10.15.0.66' > > > > sock = UDPSocket.open > > sock.bind($IP1 , $port1) > > sock.connect($IP2 , $port2) > > > > > > server_thread = Thread.start do > > server = UDPSocket.open > > server.bind(nil, $port1) > > 2.times { p server.recvfrom(64) } > > end > > > > > > # now I send the message to device. > > sock.send (" my UDP message", 0) > > > > # and immediately I enter this command > > server_thread.join > > > > 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. > > > > > > > > > ------=_Part_4676_3703969.1150755250673--