diff options
author | senator <senator> | 2008-03-18 09:18:53 +0000 |
---|---|---|
committer | senator <senator> | 2008-03-18 09:18:53 +0000 |
commit | a860976a62d206a1de5aa46f624bcac0036f47c2 (patch) | |
tree | d6b3d232a045b887b984b1ad5cd866d93a5768cd | |
parent | 42f978a143b3bf2b2f8696ef70ccf712ed147350 (diff) |
better error handling on socket
-rw-r--r-- | client/sendrecieve.cc | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/client/sendrecieve.cc b/client/sendrecieve.cc index 914b4af..8d6caf4 100644 --- a/client/sendrecieve.cc +++ b/client/sendrecieve.cc @@ -90,10 +90,11 @@ void SendRecieve::makeConnection(QDomDocument *xml_req) void SendRecieve::myTcpWrite(char *msg, int len) { - if(tcpConnected == TCP_CONNECTED) + if(tcpConnected == TCP_CONNECTED) { tcpsocket->write(msg, len); - else + } else { printf("TCP socket not initialized!\n"); + } } void SendRecieve::myHostFound() // slot @@ -120,11 +121,18 @@ void SendRecieve::myDisconnected() // slot has_result = true; } -void SendRecieve::myError(QAbstractSocket::SocketError) // slot +void SendRecieve::myError(QAbstractSocket::SocketError socketError) // slot { tcpConnected = TCP_ERROR; - QMessageBox::information(NULL, tr("Pracro"), tr("Couldn't connect to server.\nPlease contact a system administrator to resolve the problem.")); - exit(1); + printf("socket_error: %d\n", socketError); + switch (socketError) { + case 2 : + QMessageBox::information(NULL, tr("Pracro"), tr("Couldn't connect to server.\nPlease contact a system administrator to resolve the problem.")); + exit(1); + break; + default : + printf("default\n"); + } } void SendRecieve::myReadyReadHandler() |