Dropped Connection Problems

I'm working on a Ruby library to connect to AOL AIM servers with the
OSCAR protocol. The client works fine, but after a minute or so the
server drops my connection. I don't get any notification about this,
I just get the following error:

../oscar/flapmgr.rb:28:in `get': undefined method `unpack' for
nil:NilClass (NoMethodError)
        from ./oscar/snacmgr.rb:61:in `get'
        from ./oscar/connection.rb:25:in `process'
        from ./oscar/session.rb:53:in `tick'
        from ./oscar/session.rb:52:in `each'
        from ./oscar/session.rb:52:in `tick'

The code in question is:

  class FLAPManager
    def get
      buff = @conn.read(6)
      header = buff.unpack("CCnn")

      ...
    end

When the connection is dropped, Socket#read just returns nil. Why is
this? Is there any way to have an exception raised when a server
drops a connection. When a client breaks a connection to a server,
the server gets an exception, so I don't see why this wouldn't be
possible.

On another note, if anyone out there has any experience with the OSCAR
protocol, I would greatly appreciate any assistance you could give me.
The source is available in CVS at
http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/oscar/?cvsroot=oscar
.. Everything works _perfectly_ until the server suddenly drops my
connection. I'd really like some help with this.

Thanks in advance,
Bill Atkins

I've been looking at this, and I'm curious as to why you're using Socket#read rather than BasicSocket#recv or Socket#recvfrom. Of course, when I replace buff = @conn.read(6) with buff=@conn.recv(6), I get an IOError during the initialization of the BOS segment; I'm not sure why. Have you tried this yet, and if so why did you decide against it? Any idea why I'm having this error?

On the other note, I've got a few months of experience with the OSCAR protocol; I spent last summer writing a packet parser for it. I'd be interested in helping you out.

Austin McDonald

Bill Atkins wrote:

···

I'm working on a Ruby library to connect to AOL AIM servers with the
OSCAR protocol. The client works fine, but after a minute or so the
server drops my connection. I don't get any notification about this,
I just get the following error:

../oscar/flapmgr.rb:28:in `get': undefined method `unpack' for
nil:NilClass (NoMethodError)
       from ./oscar/snacmgr.rb:61:in `get'
       from ./oscar/connection.rb:25:in `process'
       from ./oscar/session.rb:53:in `tick'
       from ./oscar/session.rb:52:in `each'
       from ./oscar/session.rb:52:in `tick'

The code in question is:

class FLAPManager
   def get
     buff = @conn.read(6)
     header = buff.unpack("CCnn")

     ...
   end

When the connection is dropped, Socket#read just returns nil. Why is
this? Is there any way to have an exception raised when a server
drops a connection. When a client breaks a connection to a server,
the server gets an exception, so I don't see why this wouldn't be
possible.

On another note, if anyone out there has any experience with the OSCAR
protocol, I would greatly appreciate any assistance you could give me.
The source is available in CVS at
http://rubyforge.org/cgi-bin/viewcvs/cgi/viewcvs.cgi/oscar/?cvsroot=oscar
.. Everything works _perfectly_ until the server suddenly drops my
connection. I'd really like some help with this.

Thanks in advance,
Bill Atkins