Changeset 149

Show
Ignore:
Timestamp:
03/13/09 10:42:47 (15 years ago)
Author:
bhilburn
Message:

Bug fixes to the socket_comm functions. Minor changes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/bhilburn/src/include/vtcross/socket_comm.h

    r147 r149  
    1111#include <cstdlib> 
    1212#include <cstring> 
     13#include <netdb.h> 
    1314#include <netinet/in.h> 
    14 #include <netdb.h> 
    1515#include <stdint.h> 
    1616#include <sys/types.h> 
     
    2525ReadMessage(int32_t socketFD, char* msgBuffer) 
    2626{ 
    27     ssize_t msgLength; 
    28      
    29     msgLength = recv(socketFD, msgBuffer, 256, MSG_PEEK); 
    30     for(size_t i = 0; i < 256; i++) { 
     27    ssize_t msgLength = recv(socketFD, msgBuffer, 256, MSG_PEEK); 
     28 
     29    size_t i; 
     30    for(i = 0; i < 256; i++) { 
    3131            if(strcmp(&msgBuffer[i], "\0") == 0) 
    3232            break; 
     
    8080 
    8181    ssize_t numSentBytes = send(socketFD, message, (strlen(message) + 1), 0); 
    82     if(numSentBytes < 0) 
    83         ERROR("Error sending to server."); 
    84     else if(numSentBytes == 0) 
     82    if(numSentBytes < 0) { 
     83        ERROR(1, "Error sending to server."); 
     84    } 
     85    else if(numSentBytes == 0) { 
    8586        LOG("socket_comm::SendMessage - Server closed the socket.\n"); 
     87    } 
    8688    
    8789    return numSentBytes;