bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

couple CommonC++ questions


From: Jeremy Noetzelman
Subject: couple CommonC++ questions
Date: Tue, 5 Feb 2002 23:46:42 -0800 (PST)

I'm working on a server application (FreeBSD 4.3, CommonC++ 1.9.5), using
a SocketService instantiation as well as a class derived from SocketPort
(call it mySocketPort)

--begin code

   SocketService * svc = new SocketService(0);
   InetHostAddr host("localhost);
   TCPSocket socket(host, 6275);

   mySocketPort* newConnection = NULL;

   while(1) {
      cerr << svc->getCount() << " clients are connected."
           << endl << flush;

      newConnection = new mySocketPort(svc, socket);
      newConnection->setCompletion(false);

      cerr << "connection accepted" << endl << flush;
   }

-- end code

After compiling and launching the application, as expected, cerr output
indicates that the service has 0 clients:

   0 clients are connected.

I then use telnet to connect to port 6275, and expect the service thread
to indicate that a client has connected.  Output verifies this:

   connection accepted
   1 clients are connected.

I then close that connection and reconnect.  I would expect normally for
the client count to decrement to 0, then increment to 1 again, with cerr
output indicating that the client count is again 1.  Instead, I get this:

   connection accepted
   2 clients are connected.

clearly, the service is not detaching clients properly as the client count
is not properly updated when a client disconnects.

I've enhanced mySocketPort to implement Disconnect().  Disconnect() simply
logs to cerr when it is called.  I also added a cerr log to the destructor
to track calls to it.

All works well while the first client is connected, but neither
Disconnect() or the destructor are called when the client disconnects.

Setting mySocketPort.setTimer() to a low value and waiting for it to
timeout calls my Expired() implementation properly.

I'm hoping someone can shed some light on this for me and explain why the
SocketService isn't detecting socket disconnections.

Thanks,

Jeremy Noetzelman




reply via email to

[Prev in Thread] Current Thread [Next in Thread]