Changeset 174

Show
Ignore:
Timestamp:
03/21/09 17:06:46 (15 years ago)
Author:
bhilburn
Message:

Moving the SendMessage? function over to a const char*, which (I think) should be
the proper way to do it. Still need someone to explain the '\0000' in the old
function...

Location:
vtcross/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/include/vtcross/socketcomm.h

    r170 r174  
    2626/* TODO 
    2727 */ 
    28 int32_t SendMessage(int32_t socketFD, char* message); 
     28//int32_t SendMessage(int32_t socketFD, char* message); 
     29int32_t SendMessage(int32_t socketFD, const char* message) ; 
    2930 
    3031 
  • vtcross/trunk/src/lib/socketcomm/socketcomm.cpp

    r173 r174  
    1414#include <netinet/in.h> 
    1515#include <stdint.h> 
     16#include <string> 
    1617#include <sys/types.h> 
    1718#include <sys/socket.h> 
     
    7576 
    7677     
     78/* 
    7779int32_t 
    7880SendMessage(int32_t socketFD, char* message)  
     
    8385    strcat(message, "\0000"); 
    8486 
     87    ssize_t numSentBytes = send(socketFD, message, (strlen(message) + 1), 0); 
     88    if(numSentBytes < 0) { 
     89        ERROR(1, "Error sending to server."); 
     90    } 
     91    else if(numSentBytes == 0) { 
     92        LOG("socket_comm::SendMessage - Server closed the socket.\n"); 
     93    } 
     94    
     95    return numSentBytes; 
     96} 
     97*/ 
     98 
     99// TODO this function is here to handle calls to send const char* messages. Note 
     100// that the std::string.c_str() function auto-appends a null character at the 
     101// end of the cstring, so the strcat function call in the previous function 
     102// isn't necessary here... I think... although I still don't really understand 
     103// what exactly that call is for. 
     104int32_t 
     105SendMessage(int32_t socketFD, const char* message)  
     106{ 
    85107    ssize_t numSentBytes = send(socketFD, message, (strlen(message) + 1), 0); 
    86108    if(numSentBytes < 0) {