[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
exceptions and threads
From: |
Greg Hookey |
Subject: |
exceptions and threads |
Date: |
19 Feb 2003 15:29:17 -0800 |
Hi,
I was wondering if someone could help me sort out a problem that I am
having with commoncpp2 on Debian Linux.
I have an object, MesgClient, which has a connect() method. The
connect() method attempts to spin a NetworkThread, which is defined as
follows (I have omitted the private declarations as they are
irrelevant):
class NetworkThread : public ost::Thread {
public:
NetworkThread( MesgClientI *master );
virtual ~NetworkThread();
virtual void run();
void final() { delete this; };
void requestExit();
};
The run() method of NetworkThread is defined as follows:
void NetworkThread::run() {
ServerConfig config = mesgClient->getServerConfig();
ost::InetHostAddress addr = config.getServerName().c_str();
ost::TCPStream server( addr, config.getPort(), 2048, true );
while( quit == false ) {
// do stuff
ost::Thread::sleep( 50 );
}
server.sync();
ost::Thread::exit();
}
The connect() method of MesgClient is defined as follows:
void MesgClient::connect( std::string &serverName, short port ) throw ()
{
serverConfig.setServerName( serverName );
serverConfig.setPort( port );
/* startNetworkThread may throw an ost::Socket *
* if an exception occurs during networkThread->run().
* The exception will be rethrown as MesgClientEx when
* I get the ost exception sorted out.
*/
try {
startNetworkThread();
} catch ( ost::Socket *s ) {
std::cerr << "connect(): exception caught" << std::endl;
}
ost::Thread::sleep( 250 );
if( networkThreadRunning() == true ) {
startPollThread();
}
}
I have a test program that I run, that creates a MesgClient, and then
runs the connect() method. I supply an unresolvable hostname to the
client in order to have the exception thrown. Currently, when I run the
program, I get the following output:
MesgClient() created!
Aborted
So, I am wondering if I am missing something here with respect to
exception handling here, or maybe this is a bug. Consequently, if I run
the code with a correct host name, the program runs to termination and
exits correctly.
Any help here would be appreciated.
Greg
--
Greg Hookey <address@hidden>
www.deadly.ca
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- exceptions and threads,
Greg Hookey <=