Definition at line 40 of file AlertRelay.h. References AcceptWithoutBlocking(), IsReady(), mClientSocket, and mListenSocket. Referenced by Impala::Application::SDash::AlertWindow::ButtonSelectionEvent(). 00041 { 00042 if (!IsReady()) 00043 { 00044 printf("AlertRelay not ready; unable to send message: %s", msg); 00045 return 1; 00046 } 00047 00048 std::string completeMsg = "05" + msg; 00049 if (mClientSocket == INVALID_SOCKET) 00050 { 00051 //if (AcceptWithoutBlocking(&mListenSocket, &mClientSocket) != 0) 00052 //{ 00053 // closesocket(mClientSocket); 00054 // mClientSocket = INVALID_SOCKET; 00055 // return 2; // transmission error; exit 00056 //} 00057 AcceptWithoutBlocking(&mListenSocket, &mClientSocket); 00058 } 00059 //else 00060 //{ 00061 // // test if recent client is still alive; 00062 // // SK: this impl. does NOT work! 00063 // fd_set currentClientSocketSet; 00064 // FD_ZERO(¤tClientSocketSet); 00065 // FD_SET(mClientSocket, ¤tClientSocketSet); 00066 // TIMEVAL timeVal = {2, 0}; 00067 // int validmClientSockets = select(0, 0, ¤tClientSocketSet, 0, &timeVal); 00068 // if (validmClientSockets < 1) 00069 // { 00070 // printf("client socket has become obsolete\n"); 00071 00072 // if (AcceptWithoutBlocking(&mListenSocket, &mClientSocket) != 0) 00073 // return 3; // transmission error; exit 00074 // } 00075 //} 00076 00077 //int iResult, iSendResult; 00078 if (mClientSocket != INVALID_SOCKET) 00079 { 00080 int len = completeMsg.length(); 00081 int iSendResult = send( mClientSocket, completeMsg.c_str(), len, 0); 00082 int err = WSAGetLastError(); 00083 if (iSendResult == SOCKET_ERROR) 00084 { 00085 printf("send failed: %d\n", err); 00086 printf("Transmission of message failed: %s\n", completeMsg.c_str()); 00087 closesocket(mClientSocket); 00088 mClientSocket = INVALID_SOCKET; 00089 return 4;; 00090 } 00091 printf("Message sent: %s\n", completeMsg.c_str()); 00092 } 00093 else 00094 printf("Transmission of message skipped: %s\n", completeMsg.c_str()); 00095 00096 return 0; 00097 }
Here is the call graph for this function:
|