bug-commoncpp
[Top][All Lists]
Advanced

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

RE: TCPSession bug? Questions


From: Ian Gough
Subject: RE: TCPSession bug? Questions
Date: Thu, 30 Jan 2003 16:17:05 -0500

> -----Original Message-----
> From: Ari Johnson [mailto:address@hidden 
> Sent: Wednesday, January 29, 2003 1:57 PM
> To: Ian Gough
> Cc: address@hidden
> Subject: Re: TCPSession bug? Questions
> 
> 
> 
> I use 'tcpstream' and have found that the '!' (not) operator 
> works well to determine if it is connected:
>   tcpstream stream;
>   bool disconnected = !stream;
>   bool connected = !!stream;
> 
> Ari Johnson
> 

The docs imply that tcpstream is not threadsafe, which is no good for my
app. I have tried using TCPSession::isConnected() but under the
circumstances shown in the test app, isConnected() always returns true,
at least running on Windows it does.

Ari, have you tried determining if a disconnect has occurred on Windows
using tcpstream?

> On Wed, 29 Jan 2003, Ian Gough wrote:
> 
> > I need some help determining if TCPSession is working 
> correctly. The 
> > included code was run on Windows. It is a slight 
> modification of the 
> > tcpthread.cpp demo. If you build it as-is, it creates a 
> server socket 
> > that accepts a connection on port 4096. When you connect to it with 
> > telnet, it prints out banner messages and then echos back 
> the decimal 
> > value of any key you press in the telnet session, except 
> for 'q' which 
> > causes the connection to close. It is set up to (in theory) throw 
> > exceptions in the session thread using
> >  
> >  setException( Thread::throwException );
> >  
> > If you kill telnet while in the session, no exception gets 
> thrown to 
> > tell the server that the connection has closed. Also, the 
> read of the 
> > tcp stream returns the last thing sent on the socket from 
> telnet and 
> > the read thinks that it is getting a continuous stream of 
> characters.
> >  
> > 1) Should an exception be thrown on connection closure?
> > 2) If not, how do you determine if the connection is closed or not?
> > 
> > Also, if you uncomment line 140 and comment out line 141 so 
> that the 
> > session thread is detached instead of started, you get no output on 
> > telnet from the session. This doesn't seem particularly 
> useful, as it 
> > appears to be a socket set up with no ability to send data upon it.
> > 
> 
> 





reply via email to

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