Index: vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp
===================================================================
--- vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp	(revision 95)
+++ vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp	(revision 96)
@@ -2,8 +2,12 @@
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
 #include "tinyxml.h"
 #include "tinystr.h"
-#include "socket/ServerSocket.h"
-#include "socket/SocketException.h"
+#include <arpa/inet.h>
+//#include "socket/ServerSocket.h"
+//#include "socket/SocketException.h"
 
 using namespace std;
@@ -471,8 +475,6 @@
    	// Start socket server
      	int sockfd, newsockfd, clilen;
-        int peer_len = sizeof(struct sockaddr);
      	struct sockaddr_in serv_addr, cli_addr;
-     	struct sockaddr_in peer;
-
+        char str[20];
 
      	// Setup server socket connection
@@ -497,10 +499,6 @@
           		error("ERROR on accept");
 
-        if(getpeername(newsockfd, (struct sockaddr *) &peer, (socklen_t*)&peer_len) == -1) {
-            perror("getpeername() failed");
-            return -1;
-        }
-
-        printf("Received a connection from a Cognitive Engine with IP address: %s\n\n",inet_ntoa(peer.sin_addr));
+        inet_ntop(AF_INET,&(cli_addr.sin_addr),str,20); 
+        printf("Received a connection from a Cognitive Engine with IP address: %s\n\n",str);
 
 		// Begin parsing the messages
Index: vtcross/trunk/CR_shell/src/main_cognitive_engine.cpp
===================================================================
--- vtcross/trunk/CR_shell/src/main_cognitive_engine.cpp	(revision 75)
+++ 	(revision )
@@ -1,310 +1,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <iostream>
-
-using namespace std;
-
-struct CE_Info {
-    int numUtilities;
-    int numParameters;
-    int numObservables;
-};
-
-struct Utility {
-    char name[50];
-    char units[50];
-    char goal[50];
-   /* string name;
-    string units;
-    string goal;*/
-    float target;
-};
-
-struct Affect {
-    Utility u; 
-    //string relation;
-    char relation[50];
-};      
-
-struct Parameter {
-    /*string name;
-    string units;*/
-    char name[50];
-    char units[50];
-    float min;
-    int numAffects; 
-    Affect affection_list[10];
-    float max;
-    float step;
-};      
-        
-struct Observable {
-    //string name;
-    char name[50];
-    Affect affection_list[10];
-    int numAffects;
-};
-
-// error handling
-void error(char *msg)
-{
-    perror(msg);
-    exit(0);
-}
-
-void ReadMessage(int socket,char * buffer) {
-    int i,n;
-
-    n = recv(socket,buffer,256,MSG_PEEK);
-    for(i=0;i<256;i++){
-	    if(strcmp(&buffer[i],"\0") == 0) break;
-    }
-    n = recv(socket,buffer,i+1,0);
-    if (n < 0) 
-         error("ERROR reading from socket");
-//    printf("ReadMessage:%s %d\n",buffer,n);
-}
-
-
-int GetUtility(int sockfd, Utility uList[], CE_Info *ce_info)
-{
-    char buffer[256];
-    int i;
-
-    // read unitilities
-    // numUtilities
-    bzero(buffer,256);
-    ReadMessage(sockfd,buffer);
-    ce_info->numUtilities = atoi(buffer);
-    //printf("number of utilities: %d\n", ce_info->numUtilities);
-        
-    for (i = 0; i < ce_info->numUtilities; i++){
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-	    //printf("Name: %s\n", buffer);
-        strcpy(uList[i].name, buffer);
-                 
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-	    //printf("Units: %s\n", buffer);
-        strcpy(uList[i].units, buffer);
-
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-        //printf("Goal: %s\n", buffer);
-        strcpy(uList[i].goal, buffer);
-        
-	    bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-        //printf("Target: %s\n", buffer);
-        uList[i].target = atof(buffer);
-    }
-    return 1;
-}
-
-
-int GetParameter(int sockfd, Parameter pList[], CE_Info *ce_info)
-{
-    char buffer[256];
-    int i, j;
-
-    // numParameters
-    bzero(buffer,256);
-    ReadMessage(sockfd,buffer);
-    ce_info->numParameters = atoi(buffer);
-    //printf("number of parameters: %d\n", ce_info->numParameters);
-        
-    for (i = 0; i < ce_info->numParameters; i++){
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-	    //printf("Name: %s\n", buffer);
-        strcpy(pList[i].name, buffer);
-                 
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-	    //printf("Units: %s\n", buffer);
-        strcpy(pList[i].units, buffer);
-
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-        //printf("Min: %s\n", buffer);
-        pList[i].min = atof(buffer);
-        
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-        //printf("Max: %s\n", buffer);
-        pList[i].max = atof(buffer);
-        
-	    bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-        //printf("Step: %s\n", buffer);
-        pList[i].step = atof(buffer);
-    
-        // numAffects
-        bzero(buffer,256);
-        ReadMessage(sockfd,buffer);
-        pList[i].numAffects = atoi(buffer);
-        //printf("number of affects: %d\n", pList[i].numAffects);
-        
-        for (j = 0; j < pList[i].numAffects; j++){
-            bzero(buffer,256);
-	        ReadMessage(sockfd,buffer);
-	        //printf("Utility name: %s\n", buffer);
-            strcpy(pList[i].affection_list[j].u.name, buffer);
-                 
-            bzero(buffer,256);
-	        ReadMessage(sockfd,buffer);
-	        //printf("Relation: %s\n", buffer);
-            strcpy(pList[i].affection_list[j].relation, buffer);
-        }
-    }
-    return 1;
-}
-
-
-int GetObservable(int sockfd, Observable oList[], CE_Info *ce_info)
-{
-    char buffer[256];
-    int i,j;
-
-    // numParameters
-    bzero(buffer,256);
-    ReadMessage(sockfd,buffer);
-    ce_info->numObservables = atoi(buffer);
-    //printf("number of observables: %d\n", ce_info->numObservables);
-        
-    for (i = 0; i < ce_info->numObservables; i++){
-        bzero(buffer,256);
-	    ReadMessage(sockfd,buffer);
-	    //printf("Name: %s\n", buffer);
-        strcpy(oList[i].name, buffer);
-                 
-        // numAffects
-        bzero(buffer,256);
-        ReadMessage(sockfd,buffer);
-        oList[i].numAffects = atoi(buffer);
-        //printf("number of affects: %d\n", oList[i].numAffects);
-        
-        for (j = 0; j < oList[i].numAffects; j++){
-            bzero(buffer,256);
-	        ReadMessage(sockfd,buffer);
-	        //printf("Utility name: %s\n", buffer);
-            strcpy(oList[i].affection_list[j].u.name, buffer);
-                 
-            bzero(buffer,256);
-	        ReadMessage(sockfd,buffer);
-	        //printf("Relation: %s\n", buffer);
-            strcpy(oList[i].affection_list[j].relation, buffer);
-        }
-    }
-    return 1;
-}
-
-
-int GetXMLFromServer(int sockfd, Utility uList[], Parameter pList[], 
-        Observable oList[], CE_Info *ce_info)
-{
-    // get utilities
-    GetUtility(sockfd, uList, ce_info);
-    
-    // get parameters
-    GetParameter(sockfd, pList, ce_info);
-
-    // read obervables
-    GetObservable(sockfd, oList, ce_info);
-
-    printf("xml reception done\n");
-    
-    return 1;
-}
-
-void print_current_config(Utility uList[], Parameter pList[], 
-        Observable oList[], CE_Info * ce_info) 
-{    
-    int i = 0;
-    int j = 0;
-
-    // utilities
-    for(i = 0; i < ce_info->numUtilities ; i++) {
-        cout << "Utility:  " << uList[i].name << endl;
-        cout << "     Units:  " << uList[i].units << endl;
-        cout << "     Goal:   " << uList[i].goal << endl;
-        cout << "     Target: " << uList[i].target << endl;
-    }
-                       
-    // parameters                        
-    for(i = 0; i < ce_info->numParameters; i++) {
-        cout << "Parameter:  " << pList[i].name << endl;
-        cout << "       Units:   " << pList[i].units << endl;
-        cout << "       Min:     " << pList[i].min << endl;
-        cout << "       Max:     " << pList[i].max << endl;
-        cout << "       Step:    " << pList[i].step << endl;
-        for(j = 0; j < pList[i].numAffects; j++) {
-            cout << "       Affect: " << pList[i].affection_list[j].u.name << " -> " << pList[i].affection_list[j].relation << endl;
-        }
-    }
-
-    // observables
-    for(i = 0; i < ce_info->numObservables; i++) {
-        cout << "Observable:  " << oList[i].name << endl;
-        for(j = 0; j < oList[i].numAffects; j++) {
-            cout << "       Affect: " << oList[i].affection_list[j].u.name << " -> " << oList[i].affection_list[j].relation << endl;
-        }
-    }
-}
-
-
-// main client socket
-int main(int argc, char *argv[])
-{
-    Utility uList[10];
-    Parameter pList[10];
-    Observable oList[10];
-    CE_Info ce_info;
-
-    int sockfd, portno;
-    struct sockaddr_in serv_addr;
-    struct hostent *server;
-
-    // setup client socket connection
-    if (argc < 3) {
-       fprintf(stderr,"usage: %s hostname port\n", argv[0]);
-       exit(0);
-    }
-    // server name
-    server = gethostbyname(argv[1]);
-    if (server == NULL) {
-        fprintf(stderr,"ERROR, no such host\n");
-        exit(0);
-    }
-    // port no.
-    portno = atoi(argv[2]);
-    // socket file descriptor
-    sockfd = socket(AF_INET, SOCK_STREAM, 0);
-    if (sockfd < 0) 
-        error("ERROR opening socket");
-    // initiate struct socketaddr_in
-    bzero((char *) &serv_addr, sizeof(serv_addr));
-    serv_addr.sin_family = AF_INET;
-    serv_addr.sin_port = htons(portno);
-    bcopy((char *)server->h_addr, 
-         (char *)&serv_addr.sin_addr.s_addr,
-         server->h_length);
-    // cast sockaddr_in to sockaddr
-    if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) 
-        error("ERROR connecting");
-    
-    // get xml info from server
-    GetXMLFromServer(sockfd, uList, pList, oList, &ce_info);
-
-    //printf("utility:\n name: %s, units: %s, goal: %s, target: %f\n", 
-    //        uList[0].name, uList[0].units, uList[0].goal, uList[0].target);
-    
-    print_current_config(uList, pList, oList, &ce_info); 
-
-
-  return 0;
-}
