Show
Ignore:
Timestamp:
03/23/09 10:51:57 (15 years ago)
Author:
bhilburn
Message:

Abandoning the RemoteComponent? struct; migrating to a simple socketFD
and boolean field.

Files:
1 modified

Legend:

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

    r186 r187  
    7676} 
    7777 
    78  
    79 /* TODO see notes in socketcomm.h. This function, and the RemoteComponent 
    80  * struct, need a code review to make sure it is ready to be used rather 
    81  * than ClientSocket() 
    82  */ 
    83 void 
    84 CreateClientSocket(struct RemoteComponent* serverInfo) 
    85 { 
    86     if(serverInfo == NULL) 
    87         ERROR(1, "CreateClientSocket received null struct pointer.\n"); 
    88  
    89     struct hostent *server = gethostbyname(serverInfo->serverName.c_str()); 
    90     if(server == NULL) 
    91         ERROR(1, "No server found by that hostname."); 
    92          
    93     serverInfo->socketFD = socket(AF_INET, SOCK_STREAM, 0); 
    94     if(serverInfo->socketFD < 0)  
    95         ERROR(1, "Error opening socket"); 
    96  
    97     struct sockaddr_in serv_addr; 
    98     memset((void *) &serv_addr, 0, sizeof(serv_addr)); 
    99     serv_addr.sin_family = AF_INET; 
    100     serv_addr.sin_port = htons(serverInfo->serverPort); 
    101     memcpy((char *) &serv_addr.sin_addr.s_addr, (char *) server->h_addr, \ 
    102             server->h_length); 
    103  
    104     if(connect(serverInfo->socketFD, (struct sockaddr *) &serv_addr, \ 
    105             sizeof(serv_addr)) < 0)  
    106         ERROR(1, "Error connecting to remote socket."); 
    107 } 
    108  
    10978     
    11079/* TODO I'm fairly certain this function is unnecessary, see function below for more details...