in reply to IO::Socket to me. . . or why won't you stay?

As far as I know, most WHOIS servers hang up on you after each query, so you will have to reconnect explicitly. You can recycle the socket object by forcing it to reconnect, which should save you some overhead. Right now you're creating a whole new socket object each time.

I'm not sure why the connected() function isn't operating correctly, but it might not be a good indicator anyway. Assume you're going to get ditched.
  • Comment on Re: IO::Socket to me. . . or why won't you stay?

Replies are listed 'Best First'.
Re: Re: IO::Socket to me. . . or why won't you stay?
by Hero Zzyzzx (Curate) on Aug 01, 2001 at 18:48 UTC

    Forgive me, but how would you force it to reconnect without creating a new socket? If it's true that a whois server hangs up after each query, then reconnecting without creating a new socket seems like a good compromise.

    Thanks, tadman.

      It seems that I'm making assumptions about the functionality of IO::Socket::INET that just aren't true. For example, you can't really reconnect unless you jump through a bunch of hoops. The $socket->connect() method, for example, is no more robust than the internal one. You need to resolve your addresses first using gethostbyaddr, which is inconvenient, to say the least. So it can be done, but the cost is too high to make it practical.

      Maybe this will be fixed in an upcoming release.

      In the interim, recreating the socket doesn't seem like such a big deal after all. It will certainly work.

        Yeah, it does work and works fine when I create a new socket for each request. I guess I just like persistent connections, like Apache::DBI, but this may not be possible with a socket.

        Doing this I kind of feel like a script-kiddie, like I'm not really understanding what's happening, even though I can get it work and have read the docs, camel, and Cookbook entries on IO::Socket.

        Oh well. I'm sure true socket enlightenment is close. . .