More on sockets

djberg96 on 2002-01-16T01:25:56

So, I decide to screw around with another problem today that's been giving me grief. First, I had to deal with "unable to allocate address", which screwed me up until I realized that I had forgotten to modify my code when the host name and ip address of our (ex) production box had changed.

That should fix everything, right? Wrong. I'm using the Net::SSH::Perl module, trying to connect to a series of machines and do a couple of commands. Sometimes it works, sometimes it doesn't and I get "permission denied". After stepping through the debugger, banging my head on the table for a while and chugging an extra Coke for good luck, I finally narrow it down to the fact that one machine seems to be griping about the cipher that I'm using. I decide to use the default.

That should fix everything, right? Wrong again. I notice some strange errors stored in $!. The errors "bad file descriptor" and "illegal seek" start showing up. I think to myself, "$self, this is eerily familiar to the other problem I was having in that other program where I use sockets." So I bang my head on the table some more, drink another Coke and tinker around a bit more...

What do I discover? Something is seriously wrong, and it ain't my code. Whenever I create a single object, and connect to a single host, everything is fine. However (comma), when I make connections within a "foreach" loop odd things start to happen. This is bad. This is very bad. I play with $| - no luck. I am now virtually certain that there is an IO bug somewhere in Perl. IO::Socket? IO::Select? I've already got the evidence for Net::SSH::Perl set up for a post. I'm going to put together a similar test for IO::Socket tomorrow and see if I get similar results. I'm about 99% certain I will. I don't completely understand why those errors are fucking up my programs, but there's no other explanation. They work by themselves and fail inside of loops.

This is just fucking great. A bug in IO::Socket will grind my work to a screeching halt if that turns out to be the case. So, what do I do? Go back to system calls as much as possible? Wrap huge chunks of code inside eval statements? I'll probably lose my cool tomorrow if it turns out to be a bug in Perl, unless it's easily fixed.

There's always Ruby or Python. Java is even starting to look good now. Maybe I've had too much liquor.


The problem is the beverage

chaoticset on 2002-01-16T01:51:40

You need something with higher octane, so to speak. Coke is heresy; Mountain Dew and coffee are the only true beverages. Everything else is nourishment (milk and water) or escapism (beer). ;)