Show
Ignore:
Timestamp:
07/28/09 23:23:14 (15 years ago)
Author:
trnewman
Message:

Added DSA CBR reference implementation.
Added simple python example application for DSA CBR.
Added GNUradio python application that uses CROSS and the DSA CBR.

Fixed several bugs in the socket interface.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/lib/socketcomm/socketcomm.cpp

    r232 r389  
    3434// TODO also, it appears that this function can, at maximum, receive 256 bytes 
    3535// without causing a buffer overflow. can someone confirm/deny? 
    36 void 
     36int32_t 
    3737ReadMessage(int32_t socketFD, char* msgBuffer) 
    3838{ 
     
    4141    // Messages are termination with a "\0" to denote EOM. 
    4242    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. 1\n"); 
    47  
     43    if(msgLength <= 0) { 
     44        //ERROR(1, "Remote component closed connection. 1\n"); 
     45        //LOG("Client closed connection.\n"); 
     46        return -1; 
     47    } 
    4848    size_t i; 
    4949    for(i = 0; i < 256; i++) { 
     
    5454    // Read the message into msgBuffer 
    5555    msgLength = recv(socketFD, msgBuffer, i + 1, 0); 
    56     if(msgLength < 0) 
    57         ERROR(1, "Error reading from socket.\n"); 
    58     if(msgLength == 0) 
    59         ERROR(1, "Remote component closed connection. 2\n"); 
     56    if(msgLength <= 0) { 
     57        //ERROR(1, "Remote component closed connection. 1\n"); 
     58        //LOG("Client closed connection.\n"); 
     59        return -1; 
     60    } 
     61 
     62    return 1; 
    6063} 
    6164 
     
    9396 
    9497     
    95 /* TODO I'm fairly certain this function is unnecessary, see function below for more details... 
    96 int32_t 
    97 SendMessage(int32_t socketFD, char* message)  
    98 { 
    99       
    100     // TODO explain this. What, exactly, does the below line do and how does it 
    101     // affect the rest of the function? 
    102     strcat(message, "\0000"); 
    103  
    104     ssize_t numSentBytes = send(socketFD, message, (strlen(message) + 1), 0); 
    105     if(numSentBytes < 0) { 
    106         ERROR(1, "Error sending to server."); 
    107     } 
    108     else if(numSentBytes == 0) { 
    109         LOG("socket_comm::SendMessage - Server closed the socket.\n"); 
    110     } 
    111     
    112     return numSentBytes; 
    113 } 
    114 */ 
    115  
    11698// TODO this function is here to handle calls to send const char* messages. Note 
    11799// that the std::string.c_str() function auto-appends a null character at the 
     
    217199    if(clientSocket < 0) {  
    218200        //WARNING("ALERT: Could not establish connection with client socket.\n"); 
    219         return -1; 
     201        return clientSocket; 
    220202    } 
    221203    //LOG("Handling client %s\n", inet_ntoa(echoClientAddr.sin_addr));