From: Francis Cianfrocca Date: 2006-06-21T10:18:06+09:00 Subject: Re: How to get the response from a UDP socket. ------=_Part_4048_14337583.1150852683231 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline >>> What makes you say that? I'm using this code in something, and it works perfectly: socket=UDPSocket.new socket.bind('',500) socket.connect("172.16.35.131",500) socket.send(payload,0) You don't need to bind() to send() but I needed to fix the source port at 500 for stuff to work. Bind()ing to a specific address seems to actually causes weird connect() errors sometimes if you have lots of interfaces. It's unusual for the server to ignore the client source port when responding, but certainly not unheard of. <<< Your code passes an empty string to Ruby's Socket#bind, which works ok. The OP's code passed nil which is NOT ok and gives an EINVAL exception when you try to send. The server only ignores the client source port when responding if it's designed to respond on a well-known port. This isn't so unusual (NTP does it). But that's the usual reason for binding on the client side, as your example shows. (Sometimes you want to make sure you're sending from a particular address, for firewall reasons for example.) It's unusual to use connect with UDP. More typical is just to pass the server address in the send call. I can't speak to your point about weird errors on connect with specific addresses. If repeatable, that's a Ruby problem, not a UDP problem. ------=_Part_4048_14337583.1150852683231--