Changeset 222 for vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
- Timestamp:
- 03/30/09 21:38:53 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
r219 r222 41 41 // Messages are termination with a "\0" to denote EOM. 42 42 ssize_t msgLength = recv(socketFD, msgBuffer, 256, MSG_PEEK); 43 if (msgLength < 0) 44 ERROR(1, "Error reading from socket.\n"); 45 if (msgLength == 0) 46 ERROR(1, "Remote component closed connection.\n"); 43 47 44 48 size_t i; … … 51 55 msgLength = recv(socketFD, msgBuffer, i + 1, 0); 52 56 if (msgLength < 0) 53 ERROR(1, "Error reading from socket"); 57 ERROR(1, "Error reading from socket.\n"); 58 if (msgLength == 0) 59 ERROR(1, "Remote component closed connection.\n"); 54 60 } 55 61 … … 66 72 server = gethostbyname(serverName); 67 73 if(server == NULL) 68 ERROR(1, "No server found by that hostname. ");74 ERROR(1, "No server found by that hostname.\n"); 69 75 70 76 portNumber = atoi(serverPort); … … 72 78 socketFD = socket(AF_INET, SOCK_STREAM, 0); 73 79 if(socketFD < 0) 74 ERROR(1, "Error opening socket ");80 ERROR(1, "Error opening socket\n"); 75 81 76 82 memset((void *) &serv_addr, 0, sizeof(serv_addr)); … … 81 87 82 88 if(connect(socketFD, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) 83 ERROR(1, "Error connecting to remote socket. ");89 ERROR(1, "Error connecting to remote socket.\n"); 84 90 85 91 return socketFD; … … 117 123 { 118 124 ssize_t numSentBytes = send(socketFD, message, (strlen(message) + 1), 0); 119 120 ERROR(1, "Error sending to server. ");125 if(numSentBytes < 0) { 126 ERROR(1, "Error sending to server.\n"); 121 127 } 122 128 else if(numSentBytes == 0) { … … 210 216 int32_t clientSocket = accept(serverSock, NULL, NULL); 211 217 if(clientSocket < 0) { 212 WARNING("ALERT: Could not establish connection with client socket.\n");218 //WARNING("ALERT: Could not establish connection with client socket.\n"); 213 219 return -1; 214 220 }