From a860976a62d206a1de5aa46f624bcac0036f47c2 Mon Sep 17 00:00:00 2001 From: senator Date: Tue, 18 Mar 2008 09:18:53 +0000 Subject: better error handling on socket --- client/sendrecieve.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'client') 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() -- cgit v1.2.3