Hello all,
Here is the scenario:
I have a TCPServer running and accepting connections. I implemented my own MyTCPServerConnectionFactory which keeps record of the MyTCPServerConnections it creates and dispatches. This allows me to access the MyTCPServerConnection objects when they are running.
In each MyTCPServerConnection run() method, I do something like this:
^void MyTCPServerConnection::run() {
DialogSocket dialog_socket(this->socket());
std::string msg;
try {
while(dialog_socket.receiveMessage(msg)) {
// DO SOMETHING...
}
} catch (ConnectionAbortedException e) {
return;
}
std::cout << "Connection closed by foreign host...
";
}^
So far so good. The TCPServerConnection socket is blocking (I believe it is default). At some point I want to terminate the connection socket. Remember I can access the MyTCPServerConnection object, so I call my own method on the object:
^void MyTCPServerConnection::shutdown() {
this->socket().shutdown();
}^
According to the socket information I read, the call to shutdown() on a blocking socket should wake it and it does but it throws the ConnectionAborted (or WSAECONNABORTED in Winsock, I am using Windows) exception. Again according to the winsock documentation:
^WSAECONNABORTED 10053
Software caused connection abort.
An established connection was aborted by the software in your host computer, possibly due to a data transmission time-out or protocol error.^
But the UNIX documentation on socket() does not list the EACONNABORTED as an error produced by a socket but only by the accept(). So, I am confused.
To make it more complicated, if I create a DialogSocket (as a client) and connect it to a server, read block it and call shutdown(), it does not throw any exceptions but just returns 0.
I am pretty sure I am missing something somewhere...
Thank you,
Murat





