Cleaning up drivers/Cpp, Cpp/Lifxtest, virtuals, and iotrmi/C++ (revisiting the C...
[iot2.git] / iotjava / iotrmi / C++ / IoTSocketClient.hpp
index 4f5dec540f43c5293d8b41a6f7e89d4d3db10881..271d465e9fa431b7829f3183d07d2c3b64f4e38a 100644 (file)
@@ -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];