Index: vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp
===================================================================
--- vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp	(revision 69)
+++ vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp	(revision 70)
@@ -56,4 +56,17 @@
 }
 
+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);
+}
+
 // main client socket
 int main(int argc, char *argv[])
@@ -65,4 +78,5 @@
     // create a socket
     char buffer[256];
+    char buffer1[256];
     if (argc < 3) {
        fprintf(stderr,"usage %s hostname port\n", argv[0]);
@@ -87,66 +101,38 @@
     if (connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0) 
         error("ERROR connecting");
-    /*if (connect(sockfd,&serv_addr,sizeof(serv_addr)) < 0) 
-        error("ERROR connecting");*/
     
-    /*// send to server
-    printf("Please enter the message: ");
-    bzero(buffer,256);
-    fgets(buffer,255,stdin);
-    n = send(sockfd,buffer,strlen(buffer),MSG_NOSIGNAL);
-    if (n < 0) 
-         error("ERROR writing to socket");
-    bzero(buffer,256);*/
-    
-    // read back xml information
     int i;
-    Utility * uList[10];
-    Parameter * pList[10];
-    Observable * oList[10];
-    CE_Info *ce_info;
+    Utility uList[10];
+    Parameter pList[10];
+    Observable oList[10];
+    CE_Info ce_info;
 
     // read unitilities
     // numUtilities
     bzero(buffer,256);
-    n = recv(sockfd,buffer,255,0);
-    if (n < 0) 
-         error("ERROR reading from socket");
-    printf("%s\n",buffer);
-    ce_info->numUtilities = atoi(buffer);
-    printf("number of utilities: %d\n", ce_info->numUtilities);
+    ReadMessage(sockfd,buffer);
+    ce_info.numUtilities = atoi(buffer);
+    printf("number of utilities: %d\n", ce_info.numUtilities);
         
-    /*bzero(buffer,256);
-    n = recv(sockfd,buffer,255,0);
-    printf("%s ", buffer);*/
-    
-    //for (i = 0; i < ce_info->numUtilities; i++){
-    for (i = 0; i < 1; i++){
+    for (i = 0; i < ce_info.numUtilities; i++){
         bzero(buffer,256);
-        n = recv(sockfd,buffer,255,0);
-        if (n < 0) 
-            error("ERROR reading from socket");
-        printf("%s ", buffer);
-        strcpy(uList[i]->name, buffer);
+	ReadMessage(sockfd,buffer);
+	printf("Name: %s\n", buffer);
+        strcpy(uList[i].name, buffer);
                  
         bzero(buffer,256);
-        n = recv(sockfd,buffer,255,0);
-        if (n < 0)
-            error("ERROR reading from socket");
-        printf("%s ", buffer);
-        strcpy(uList[i]->units, buffer);
+	ReadMessage(sockfd,buffer);
+	printf("Units: %s\n", buffer);
+        strcpy(uList[i].units, buffer);
 
-        /*bzero(buffer,256);
-        n = recv(sockfd,buffer,255,0);
-        if (n < 0)
-            error("ERROR reading from socket");
-        printf("%s ", buffer);
-        strcpy(uList[i]->goal, buffer);*/
+        bzero(buffer,256);
+	ReadMessage(sockfd,buffer);
+        printf("Goal: %s\n", buffer);
+        strcpy(uList[i].goal, buffer);
         
-        /*bzero(buffer,256);
-        n = recv(sockfd,buffer,255,0);
-        if (n < 0)
-            error("ERROR reading from socket");
-        printf("%s ", buffer);
-        uList[i]->target, atof(buffer);*/
+	bzero(buffer,256);
+	ReadMessage(sockfd,buffer);
+        printf("Target: %s\n", buffer);
+        uList[i].target = atof(buffer);
     }
 
Index: vtcross/branches/trnewman/CR_shell/src/socket/simple_client_main.cpp
===================================================================
--- vtcross/branches/trnewman/CR_shell/src/socket/simple_client_main.cpp	(revision 66)
+++ vtcross/branches/trnewman/CR_shell/src/socket/simple_client_main.cpp	(revision 70)
@@ -9,5 +9,5 @@
     {
 
-      ClientSocket client_socket ( "localhost", 30001 );
+      ClientSocket client_socket ( "localhost", 30003 );
 
       std::string reply;
Index: vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp
===================================================================
--- vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp	(revision 69)
+++ vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp	(revision 70)
@@ -237,11 +237,12 @@
 	int n;
 
+	message.append("\0000");	
 	// Write message back to client
-    n = send(socketfd,message.c_str(),(message.size()+1),MSG_NOSIGNAL);
-    if (n<0)
-        error("Error sending to client\n");
-    printf("sent: %s\n", message.c_str());
-	
-    return n;
+    	n = write(socketfd,message.c_str(),(message.size()+1));
+    	if (n<0)
+        	error("Error sending to client\n");
+    	printf("sent: %s %i\n", message.c_str(),n);
+	
+    	return n;
 }
 
@@ -396,5 +397,5 @@
 	} else {
 		// In parent process - open cognitive engine port.
-		StartShell(30003,uList, pList, oList, &ce_info);
+		StartShell(30002,uList, pList, oList, &ce_info);
 	} 
 	
