bug-commoncpp
[Top][All Lists]
Advanced

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

Re: TCPSession bug? Questions


From: Ari Johnson
Subject: Re: TCPSession bug? Questions
Date: Wed, 29 Jan 2003 12:56:47 -0600 (CST)

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

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]