Show
Ignore:
Timestamp:
11/21/08 13:34:28 (16 years ago)
Author:
ahe
Message:

minor modification on socket operation

Location:
vtcross/branches/trnewman/CR_shell/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp

    r68 r69  
    1515 
    1616struct Utility { 
    17     char name[20]; 
    18     char units[20]; 
    19     char goal[20]; 
     17    char name[50]; 
     18    char units[50]; 
     19    char goal[50]; 
    2020   /* string name; 
    2121    string units; 
     
    3333    /*string name; 
    3434    string units;*/ 
    35     char name[20]; 
    36     char units[20]; 
     35    char name[50]; 
     36    char units[50]; 
    3737    float min; 
    3838    int numAffects;  
     
    4444struct Observable { 
    4545    //string name; 
    46     char name[20]; 
     46    char name[50]; 
    4747    Affect affection_list[10]; 
    4848    int numAffects; 
     
    9090        error("ERROR connecting");*/ 
    9191     
     92    /*// send to server 
    9293    printf("Please enter the message: "); 
    9394    bzero(buffer,256); 
     
    9697    if (n < 0)  
    9798         error("ERROR writing to socket"); 
    98     bzero(buffer,256); 
     99    bzero(buffer,256);*/ 
    99100     
    100101    // read back xml information 
    101     int counter, i; 
     102    int i; 
    102103    Utility * uList[10]; 
    103104    Parameter * pList[10]; 
     
    135136        strcpy(uList[i]->units, buffer); 
    136137 
    137         bzero(buffer,256); 
     138        /*bzero(buffer,256); 
    138139        n = recv(sockfd,buffer,255,0); 
    139140        if (n < 0) 
    140141            error("ERROR reading from socket"); 
    141142        printf("%s ", buffer); 
    142         strcpy(uList[i]->goal, buffer); 
     143        strcpy(uList[i]->goal, buffer);*/ 
    143144         
    144145        /*bzero(buffer,256); 
     
    147148            error("ERROR reading from socket"); 
    148149        printf("%s ", buffer); 
    149         strcpy(uList[i]->target, buffer);*/ 
     150        uList[i]->target, atof(buffer);*/ 
    150151    } 
    151152 
  • vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp

    r66 r69  
    239239        // Write message back to client 
    240240    n = send(socketfd,message.c_str(),(message.size()+1),MSG_NOSIGNAL); 
     241    if (n<0) 
     242        error("Error sending to client\n"); 
     243    printf("sent: %s\n", message.c_str()); 
    241244         
    242245    return n; 
     
    249252 
    250253     
    251     while(1) { 
     254//    while(1) { 
    252255                // Send parameters from struct 
    253256                sprintf(counter,"%d",ce_info->numUtilities); 
     
    256259                // utilities 
    257260        for(i = 0; i < ce_info->numUtilities; i++) { 
     261        //for(i = 0; i < 1; i++) { 
    258262                        SendMessage(socketfd,uList[i]->name); 
    259263                        SendMessage(socketfd,uList[i]->units); 
     
    263267                } 
    264268 
    265                 // parameters 
     269                /*// parameters 
    266270        sprintf(counter,"%i",ce_info->numParameters); 
    267271                SendMessage(socketfd,counter); 
     
    296300                                SendMessage(socketfd,oList[i]->affection_list[j].relation); 
    297301                        } 
    298                 } 
     302                }*/ 
    299303         
    300304 
     
    316320                }*/ 
    317321         
    318     } 
     322//    } 
    319323} 
    320324 
     
    384388        cout << "Configuration file parsing completed." << endl; 
    385389 
    386         pid = fork(); 
     390    print_current_config(uList, pList, oList, &ce_info); 
     391         
     392    pid = fork(); 
    387393        if(pid == 0) { 
    388394                // In child process - open policy engine port.