X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=iotjava%2Fiotrmi%2FC%2B%2B%2FIoTSocketClient.hpp;h=271d465e9fa431b7829f3183d07d2c3b64f4e38a;hb=ffea2cb68e5a2e1bac041fe2279620eba8d227f8;hp=4f5dec540f43c5293d8b41a6f7e89d4d3db10881;hpb=e9a65a3fa878d7451ceb4f5a2cb1bc9ee846e035;p=iot2.git diff --git a/iotjava/iotrmi/C++/IoTSocketClient.hpp b/iotjava/iotrmi/C++/IoTSocketClient.hpp index 4f5dec5..271d465 100644 --- a/iotjava/iotrmi/C++/IoTSocketClient.hpp +++ b/iotjava/iotrmi/C++/IoTSocketClient.hpp @@ -28,16 +28,12 @@ IoTSocketClient::IoTSocketClient(int iPort, const char* pStrHost, bool bReverse, IoTSocket(iPort, pResult) { struct hostent* he = NULL; - if (pResult) *pResult = false; - if ((he = gethostbyname(pStrHost)) == NULL) { - perror("IoTSocketClient: Gethostbyname error!"); return; } - if ((m_iSock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("IoTSocketClient: Socket error!"); @@ -50,7 +46,10 @@ IoTSocketClient::IoTSocketClient(int iPort, const char* pStrHost, bool bReverse, memset(&(m_addrRemote.sin_zero), 0, 8); // Make socket client wait for socket server to be ready - while (connect(m_iSock, (struct sockaddr *) &m_addrRemote, sizeof(struct sockaddr)) == -1) { } + if (connect(m_iSock, (struct sockaddr *) &m_addrRemote, sizeof(struct sockaddr)) == -1) { + perror("IoTSocketServer: Accept connection error!"); + return; + } // Send out request for reversed bits or not char temp[1];