GNU Common C++ Socket read question

A

Adam

Hi,

I'm using the GNU Common C++ library to read data from a TCPStream. In
the code below, why does the read not throw an exception if the socket
times out? (If I check the error code after the read, timeout error is
set).

Thanks,

Adam

try {
myTCPStream->read((char *) theBuffer, theLength);
}
catch ( ... ) {
if (myLog->isDebugEnabled()) {
myLog->debug("Caught stream exception.");

}
 
E

Evan Carew

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,

I'm using the GNU Common C++ library to read data from a TCPStream. In
the code below, why does the read not throw an exception if the socket
times out? (If I check the error code after the read, timeout error is
set).

Thanks,

Adam

Adam,

Did you declare the variable "myTCPStream" as "ifstream myTCPStream;" or
some other variant?
try {
myTCPStream->read((char *) theBuffer, theLength);
}
catch ( ... ) {
if (myLog->isDebugEnabled()) {
myLog->debug("Caught stream exception.");

}

Evan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFB2fkIpxCQXwV2bJARAkJNAJ9A+6TSnCneUD1QNYYDftZqXMd+1wCfWLRH
Rqc/WEdVObJDLoCwir2et1g=
=jfiI
-----END PGP SIGNATURE-----
 
A

Adam

Evan,

Thanks for your response. myTCPStream is a class member pointer to an
ost::TCPStream that is instantiated in the constructor with:

//create tcp connection
myTCPStream = new TCPStream(
address,
port,
536,
true,
timeout);

Thanks,

Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top