General Development

Raarr!!! Ruby flustrations solved – HanClinto

HanClinto

Administrator

Posts: 1828
From: Indiana
Registered: 10-11-2004
Well I'm thankful to finally have found an answer to my problems.

For a good part of the day yesterday, I couldn't figure out why I could send packets to my program from within my computer, but as soon as I tried to send packets to my computer from an external device, I got an ICMP error Destination unreachable (Port unreachable). It was really annoying, because I was following the minimalistic example from the Ruby docs extremely closely.

Long story short, I was using
server.bind(nil, 3804)

when I should have been using
server.bind('<any>', 3804)

Apparently, when you use nil, it doesn't officially bind the socket to that address, but if a packet happens to come by for that port, it will grab it.

Really annoying.

Anyways, just wanted to chronicle the solution that I found, in case by happenstance some other Googler is running into the same issue.

--clint

MastaLlama

Member

Posts: 671
From: Houston, TX USA
Registered: 08-10-2005
usually when you have ICMP errors you're supposed to fix 'em with ICBMs!
SSquared

Member

Posts: 654
From: Pacific Northwest
Registered: 03-22-2005
Aaaah, the sweet smell of success. It's always fun narrowing down on those frustrating little guys. It's not fun going through it, though. Such a small code change makes a HUGE difference.

Congratulations on figuring it out.

CPUFreak91

Member

Posts: 2337
From:
Registered: 02-01-2005
quote:
Originally posted by ssquared:
It's always fun narrowing down on those frustrating little guys. It's not fun going through it, though. Such a small code change makes a HUGE difference.


Indeed. Problems like this are one of the main reasons I enjoy programming.

Interesting that nil doesn't work in this situation. I shall keep that in mind for the future.

------------------
All Your Base Are Belong To Us!!! chown -r us ./base
"After three days without programming, life becomes meaningless.'' -- Tao of Programming Book 2

"Oh, bother," said the Borg. "We've assimilated Pooh."

"Socialism works great... if there are no people involved." -- Pastor David Ginter, Union Church of Guatemala.

My Programming and Hacker/Geek related Blog

Jari

Member

Posts: 1471
From: Helsinki, Finland
Registered: 03-11-2005
quote:
Originally posted by CPUFreak91:
Interesting that nil doesn't work in this situation. I shall keep that in mind for the future.
[/B]

It slows down working on new APIs when the functions don't report incorrect usage. Often when using incorrect arguments you just get the "unknown" error code.
So I suggest including proper error handling to your programs and libraries...
if host == nil: throw("hey buddy, did you just pass in nil to bind? Sorry we don't accept that. But use 'any' if you are not binding to any specific IP.")

------------------
Psa 32:5 I acknowledged my sin unto thee, and mine iniquity have I not hid. I said, I will confess my transgressions unto the LORD; and thou forgavest the iniquity of my sin. Selah.

[VoHW] (Help needed) [Blog] (Contact) - Truedisciple (mp3)