On Fri, Aug 22, 2003 at 03:09:59PM -0400, Dan McCormick wrote:
> Thanks, Rocco.  I appreciate the help.
> 
> I've been playing with your solution and it seems to work ok for the
> login portion of the interaction, but not the hand off to BOS (whatever
> that is -- I assume it's just the chat server).

[...]

> 
> Here's what happens:
> 
> Net::OSCAR interacts with the login server, then closes the connection. 
> At this point its debug code shows this:
> 
> login: Got authorization response.
> login: Login OK - connecting to BOS
> login: Closing.
> BOS: Connecting to 205.188.8.47:5190.
> 
> At that point, the code you suggested dies with:
> 
> Can't call method "process_one" on an undefined value at
> POE/Component/OSCAR.pm
> 
> ... which is from the process_one line in wr_ok.  
> 
> So I added some debug code to wr_ok, like so:
> 
> my $fileno = fileno($socket);
> print "in write ok: " . join(', ', $fileno, $socket->opened,
> $socket->error, $socket->clearerr, join(',', $socket->stat)) . "\n";
> 
> which at this stage yields
> 
> in write ok: , , -1, -1,
> 
> i.e., the socket appears to be invalid/non-existent.  
> 
> Adding a simple
> 
> return unless $fileno;
> 
> avoids the error, but just causes the app to hang, as both wr_ok and
> rd_ok are repeatedly called with an invalid socket.
> 
> During all this, ex_ok is never called, though it should be upon the
> disconnect, right?

Probably not.  You'd get a rd_ok, and a subsequent read would return
undef.  $! would be 0 (no error), indicating the end of the socket's
lifetime.

You might also get wr_ok, but a write on the socket would probably
return EPIPE (remote end closed the connection).

fileno() returning undef is a great way to check for a closed file.
Your problem is you're ignoring it.  Try this instead:

  unless (defined fileno $handle) {
    $kernel->select($handle);
    return;
  }

That'll stop watching closed sockets.

> Also, if I set an event to look at all the Oscar connections a few
> seconds into all this, there's still only one, and it's fileno is the
> same as that of the original socket.  Can something happen so that a
> socket and its fileno become dissociated?

Not that I'm aware of.  If you fetch the socket associated with the
file descriptor from Net::OSCAR, does calling fileno() on it return a
defined value?

My guess is that Net::OSCAR hasn't cleaned up after the closed socket
yet.  I would need to read the source/documentation on it to determine
how to force that.

> I can post the code if you're interested, but completely understand if
> you've got bigger fish to fry.

If it's not too big, go ahead and post it to the list.  If it's big,
post a link to it.  Maybe someone else can fry this one. :)

-- 
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to