Index: vtcross/trunk/src/lib/socketcomm/socketcomm.cpp
===================================================================
--- vtcross/trunk/src/lib/socketcomm/socketcomm.cpp	(revision 176)
+++ vtcross/trunk/src/lib/socketcomm/socketcomm.cpp	(revision 177)
@@ -191,76 +191,70 @@
 
 int32_t 
-AcceptTCPConnection(int32_t servSock)
-{
-    int32_t clntSock;                    /* Socket descriptor for client */
-    struct sockaddr_in echoClntAddr;
-    uint32_t clntLen;
-
-    /* Set the size of the in-out parameter */
-    clntLen = sizeof(echoClntAddr);
-
-    /* Wait for a client to connect */
-    //if ((clntSock = accept(servSock, (struct sockaddr *) &echoClntAddr, &clntLen)) < 0) {
-    if ((clntSock = accept(servSock, NULL, NULL)) < 0) {
-        return -1;
-    } 
-   
-    /* clntSock is connected to a client! */
-    
-    printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr));
-
-    return clntSock;
-}
+AcceptTCPConnection(int32_t serverSock)
+{
+    struct sockaddr_in echoClientAddr;
+
+    uint32_t clientLength = sizeof(echoClientAddr);
+
+    int32_t clientSocket = accept(serverSock, NULL, NULL);
+    if(clientSocket < 0)
+        ERROR(1, "Could establish connection with client socket.\n");
+   
+    LOG("Handling client %s\n", inet_ntoa(echoClientAddr.sin_addr));
+
+    return clientSocket;
+}
+
 
 int32_t 
 CreateTCPServerSocket(uint16_t port)
 {
-    int32_t sock;                        /* socket to create */
-    struct sockaddr_in echoServAddr; /* Local address */
-
-    /* Create socket for incoming connections */
-    if ((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+    struct sockaddr_in echoServerAddr;
+
+    int32_t localSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+    if (localSocket < 0)
         ERROR(1, "socket() failed\n");
       
-    /* Construct local address structure */
-    memset(&echoServAddr, 0, sizeof(echoServAddr));   /* Zero out structure */
-    echoServAddr.sin_family = AF_INET;                /* int32_ternet address family */
-    echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming int32_terface */
-    echoServAddr.sin_port = htons(port);              /* Local port */
+    /* Construct the local address structure */
+    memset(&echoServAddr, 0, sizeof(echoServerAddr));
+    echoServAddr.sin_family = AF_INET;
+    echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY);
+    echoServAddr.sin_port = htons(port);
 
     /* Bind to the local address */
-    if (bind(sock, (struct sockaddr *) &echoServAddr, sizeof(echoServAddr)) < 0)
+    if(bind(localSocket, (struct sockaddr *) &echoServerAddr, \
+            sizeof(echoServerAddr)) < 0)
         ERROR(1, "bind() failed\n");
 
     /* Mark the socket so it will listen for incoming connections */
-    if (listen(sock, 5) < 0) {
-        printf("listen() failed\n");
-        return 0;
-    }
-
-    return sock;
-}
+    if(listen(localSocket, 5) < 0)
+        ERROR(1, "listen() failed\n");
+
+    return localSocket;
+}
+
 
 void 
-HandleTCPClient(int32_t socketfd, Utility * uList[], Parameter * pList[], \
-        Observable * oList[], CE_Info * ce_info) 
-{
-    char buffer[256];        /* Buffer for echo string */
+HandleTCPClient(int32_t socketFD, Utility* uList[], Parameter* pList[], \
+        Observable* oList[], CE_Info* ce_info) 
+{
+    char buffer[256];
 
     /* Receive message from client */
-    bzero(buffer,256);
-    ReadMessage(socketfd,buffer);
-
-    printf("Cognitive Radio:: Message Received - %s.\n\n", buffer);
+    bzero(buffer, 256);
+    ReadMessage(socketFD, buffer);
+
+    LOG("Cognitive Radio:: Message Received - %s.\n\n", buffer);
 
     if(strcmp(buffer,"c_register") == 0) 
-	    InitializeCE(socketfd, uList, pList, oList, ce_info);
+	    InitializeCE(socketFD, uList, pList, oList, ce_info);
 
     if(strcmp(buffer,"p_register") == 0)
-	    InitializePE(socketfd, ce_info);
+	    InitializePE(socketFD, ce_info);
 
     if(strcmp(buffer,"optimize") == 0)
-	    RunSimulator(socketfd, uList, pList, oList, ce_info);
+	    RunSimulator(socketFD, uList, pList, oList, ce_info);
         
+    // TODO why aren't we doing this anymore?
     //close(socketfd);    /* Close client socket */
 }
