Index: trunk/packages/vizservers/nanovis/socket/ClientSocket.cpp
===================================================================
--- trunk/packages/vizservers/nanovis/socket/ClientSocket.cpp	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/ClientSocket.cpp	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Implementation of the ClientSocket class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -17,66 +13,55 @@
 #include "SocketException.h"
 
-ClientSocket::ClientSocket ( std::string host, int port )
+ClientSocket::ClientSocket(std::string host, int port)
 {
-  if ( ! Socket::create() )
-    {
-      throw SocketException ( "Could not create client socket." );
+    if (!Socket::create()) {
+        throw SocketException("Could not create client socket.");
     }
 
-  if ( ! Socket::connect ( host, port ) )
-    {
-      throw SocketException ( "Could not bind to port." );
+    if (!Socket::connect(host, port)) {
+        throw SocketException("Could not bind to port.");
+    }
+}
+
+const ClientSocket& ClientSocket::operator <<(const std::string& s) const
+{
+    if (!Socket::send(s)) {
+        throw SocketException("Could not write to socket.");
     }
 
+    return *this;
 }
 
-
-const ClientSocket& ClientSocket::operator << ( const std::string& s ) const
+const ClientSocket& ClientSocket::operator >>(std::string& s) const
 {
-  if ( ! Socket::send ( s ) )
-    {
-      throw SocketException ( "Could not write to socket." );
+    if (!Socket::recv(s)) {
+        throw SocketException("Could not read from socket.");
     }
 
-  return *this;
-
+    return *this;
 }
 
+void ClientSocket::set_non_blocking(bool val)
+{
+    Socket::set_non_blocking(val);
+}
 
-const ClientSocket& ClientSocket::operator >> ( std::string& s ) const
+bool ClientSocket::send(char* s, int size) const
 {
-  if ( ! Socket::recv ( s ) )
-    {
-      throw SocketException ( "Could not read from socket." );
+    bool ret = Socket::send(s, size);
+    if (!ret) {
+        throw SocketException("Could not write to socket.");
     }
 
-  return *this;
+    return ret;
 }
 
-void ClientSocket::set_non_blocking(bool val){
-        Socket::set_non_blocking(val);
-}
-
-
-bool ClientSocket::send (char* s, int size) const
+int ClientSocket::recv(char *s, int size) const
 {
-  bool ret = Socket::send (s, size);
-  if (!ret)
-    {
-      throw SocketException ( "Could not write to socket." );
+    bool ret = Socket::recv (s, size);
+    if (!ret) {
+        throw SocketException("Could not read from socket.");
     }
 
-  return ret;
+    return ret;
 }
-
-
-int ClientSocket::recv ( char* s, int size) const
-{
-  bool ret = Socket::recv (s, size);
-  if (!ret)
-    {
-      throw SocketException ( "Could not read from socket." );
-    }
-
-  return ret;
-}
Index: trunk/packages/vizservers/nanovis/socket/ClientSocket.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/ClientSocket.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/ClientSocket.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Definition of the ClientSocket class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef ClientSocket_class
-#define ClientSocket_class
+#ifndef CLIENTSOCKET_H
+#define CLIENTSOCKET_H
 
 #include "Socket.h"
@@ -21,18 +17,17 @@
 class ClientSocket : private Socket
 {
- public:
+public:
+    ClientSocket(std::string host, int port);
+    virtual ~ClientSocket()
+    {}
 
-  ClientSocket ( std::string host, int port );
-  virtual ~ClientSocket(){};
+    const ClientSocket& operator <<(const std::string&) const;
+    const ClientSocket& operator >>(std::string&) const;
 
-  const ClientSocket& operator << ( const std::string& ) const;
-  const ClientSocket& operator >> ( std::string& ) const;
+    bool send(char* s, int size) const;
+    int recv(char* s, int size) const;
 
-  bool send(char* s, int size) const;
-  int recv( char* s, int size) const;
-
-  void set_non_blocking(bool val);
+    void set_non_blocking(bool val);
 };
 
-
 #endif
Index: trunk/packages/vizservers/nanovis/socket/RenderClient.cpp
===================================================================
--- trunk/packages/vizservers/nanovis/socket/RenderClient.cpp	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/RenderClient.cpp	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- *  RenderClient.cpp: client connecting to the RenderServer
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,5 +10,4 @@
  * ======================================================================
  */
-#include <GL/freeglut.h>
 #include <stdlib.h>
 #include <sstream>
@@ -22,4 +17,6 @@
 #include <assert.h>
 
+#include <GL/glut.h>
+
 #include "RenderClient.h"
 #include "Event.h"
@@ -31,73 +28,73 @@
 
 int width, height;
-RenderClient::RenderClient(){}
-
-RenderClient::RenderClient(std::string& remote_host, int port_num){
-	//screen_size = sizeof(float)*4*512*512;	//float
-	screen_size = 3*width*height;	//unsigned byte
-	screen_buffer = new char[screen_size];
-
-	socket_num = port_num;
-	host = remote_host;
-
-	//init socket server
-	std::cout << "client running....\n";
-
-	try
-    	{
-      	  // Create the socket
-      	  client_socket = new ClientSocket(host, socket_num);
-	  //client_socket->set_non_blocking(true);
-	  fprintf(stderr, "client socket initialized\n");
-        }
-  	catch ( SocketException& e )
-    	{
-      	  std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
-    	}
-}
-
-void RenderClient::send(std::string& msg){
-      try
-	{
-	  //printf("client: send()\n");
-	  *client_socket << msg;
-	}
-      catch ( SocketException& ) {}
-}
-
-void RenderClient::receive(std::string& msg){
-      std::string buf="";
-      try
-	{
-	  fprintf(stderr, "client: receive()\n");
-	  fflush(stdout);
-	  *client_socket >> buf;
-	  msg = buf;
-	}
-      catch ( SocketException& ) {}
-}
-
-
-bool RenderClient::receive(char* s, int size){
-      try
-	{
-	  //printf("client: receive()\n");
-	  bool ret = client_socket->recv(s, size);
-	  return true;
-	}
-      catch ( SocketException& ) { return false;}
-}
-
-
-bool RenderClient::send(char* s, int size){
-      try
-	{
-	  //printf("client: receive()\n");
-	  bool ret = client_socket->send(s, size);
-	  return true;
-	}
-      catch ( SocketException& ) { return false;}
-}
-
+
+RenderClient::RenderClient()
+{
+}
+
+RenderClient::RenderClient(std::string& remote_host, int port_num)
+{
+    //screen_size = sizeof(float)*4*512*512;	//float
+    screen_size = 3*width*height;	//unsigned byte
+    screen_buffer = new char[screen_size];
+
+    socket_num = port_num;
+    host = remote_host;
+
+    //init socket server
+    std::cout << "client running....\n";
+
+    try {
+        // Create the socket
+        client_socket = new ClientSocket(host, socket_num);
+        //client_socket->set_non_blocking(true);
+        fprintf(stderr, "client socket initialized\n");
+    } catch (SocketException& e) {
+        std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
+    }
+}
+
+void RenderClient::send(std::string& msg)
+{
+    try {
+        //printf("client: send()\n");
+        *client_socket << msg;
+    } catch (SocketException&) {
+    }
+}
+
+void RenderClient::receive(std::string& msg)
+{
+    std::string buf="";
+    try	{
+        fprintf(stderr, "client: receive()\n");
+        fflush(stdout);
+        *client_socket >> buf;
+        msg = buf;
+    } catch (SocketException&){
+    }
+}
+
+bool RenderClient::receive(char* s, int size)
+{
+    try	{
+        //printf("client: receive()\n");
+        bool ret = client_socket->recv(s, size);
+        return true;
+    } catch (SocketException&) {
+        return false;
+    }
+}
+
+bool RenderClient::send(char* s, int size)
+{
+    try	{
+        //printf("client: receive()\n");
+        bool ret = client_socket->send(s, size);
+        return true;
+    } catch (SocketException&) {
+        return false;
+    }
+}
 
 RenderClient* client;
@@ -120,7 +117,7 @@
 void resize(int _width, int _height)
 {
-   delete[] client->screen_buffer;
-   client->screen_size = 3*_width*_height;
-   client->screen_buffer = new char[client->screen_size];
+    delete[] client->screen_buffer;
+    client->screen_size = 3*_width*_height;
+    client->screen_buffer = new char[client->screen_size];
 
     width = _width;
@@ -141,48 +138,43 @@
 }
 
-
-void draw_buttons(){
-  glPushMatrix();
-
-  glViewport(0, 0, width, height);
-  glMatrixMode(GL_PROJECTION);
-  glLoadIdentity();
-  glOrtho(0, width, 0, height, -0.09, 1);
-  glMatrixMode(GL_MODELVIEW);
-  glLoadIdentity();
-
-  glDisable(GL_BLEND);
-  glEnable(GL_BLEND);
-  
-  //loaddata button
-  glColor4f(0.5, 0.5, 0.5, 0.5);
-  glBegin(GL_QUADS);
+void draw_buttons()
+{
+    glPushMatrix();
+
+    glViewport(0, 0, width, height);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(0, width, 0, height, -0.09, 1);
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+
+    glDisable(GL_BLEND);
+    glEnable(GL_BLEND);
+
+    //loaddata button
+    glColor4f(0.5, 0.5, 0.5, 0.5);
+    glBegin(GL_QUADS);
     glVertex2d(10, 10);
     glVertex2d(60, 10);
     glVertex2d(60, 40);
     glVertex2d(10, 40);
-  glEnd();
-  
-
-  glDisable(GL_BLEND);
-  glPopMatrix();
-}
-
-
+    glEnd();
+
+    glDisable(GL_BLEND);
+    glPopMatrix();
+}
 
 void display()
 {
 
-	
-   if(loaded){
-     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-     //glDrawPixels(width, height, GL_RGBA, GL_FLOAT, client->screen_buffer);	
-     //bzero(client->screen_buffer, client->screen_size);
-     glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, client->screen_buffer);	
-     glFlush();
-     glutSwapBuffers();
-     return;
-   }
-
+    if (loaded) {
+        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+        //glDrawPixels(width, height, GL_RGBA, GL_FLOAT, client->screen_buffer);	
+        //bzero(client->screen_buffer, client->screen_size);
+        glDrawPixels(width, height, GL_RGB, GL_UNSIGNED_BYTE, client->screen_buffer);	
+        glFlush();
+        glutSwapBuffers();
+        return;
+    }
   
     render_done = false;
@@ -221,5 +213,4 @@
 }
 
-
 void key(unsigned char key, int x, int y)
 {
@@ -229,98 +220,96 @@
     std::string msg2;
 
-    switch (key)
-    {
-        case 27 :
-        case 'q':
-          exit(0);
-          break;
-
-	case 'l':
-	  cerr << "client: load" << endl;
-          //msgstream << "command=0" << endl;
-          msgstream << "load" << endl;
-	  msg = msgstream.str();
-	  client->send(msg);
-	  loaded = true;
-	  break;
-
-        case 'o':
-          msgstream << "command=" << "1" << endl;
-	  msg = msgstream.str();
-	  client->send(msg);
-	  break;
-
-        case '+':
-          msgstream << "command=" << "4" << endl;
-	  msg = msgstream.str();
-	  client->send(msg);
-	  break;
-
-        case '-':
-          msgstream << "command=" << "5" << endl;
-	  msg = msgstream.str();
-	  client->send(msg);
-	  break;
-
-        case 'x':
-          //msgstream << "and=" << "5" << endl;
-          msgstream << "cut x " << "off" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-        case 'X':
-          msgstream << "cut x " << " on" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-        case 'y':
-          msgstream << "cut y " << "off" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-        case 'Y':
-          msgstream << "cut y " << "on" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-        case 'z':
-          msgstream << "cut z " << "off" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-        case 'Z':
-          msgstream << "cut z " << "on" << endl;
-	  msg = msgstream.str();
-	  cerr << "client: " << msg << endl;
-	  client->send(msg);
-	  break;
-
-	default:
-	  return;
-    }
-
+    switch (key) {
+    case 27 :
+    case 'q':
+        exit(0);
+        break;
+
+    case 'l':
+        cerr << "client: load" << endl;
+        //msgstream << "command=0" << endl;
+        msgstream << "load" << endl;
+        msg = msgstream.str();
+        client->send(msg);
+        loaded = true;
+        break;
+
+    case 'o':
+        msgstream << "command=" << "1" << endl;
+        msg = msgstream.str();
+        client->send(msg);
+        break;
+
+    case '+':
+        msgstream << "command=" << "4" << endl;
+        msg = msgstream.str();
+        client->send(msg);
+        break;
+
+    case '-':
+        msgstream << "command=" << "5" << endl;
+        msg = msgstream.str();
+        client->send(msg);
+        break;
+
+    case 'x':
+        //msgstream << "and=" << "5" << endl;
+        msgstream << "cut x " << "off" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    case 'X':
+        msgstream << "cut x " << " on" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    case 'y':
+        msgstream << "cut y " << "off" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    case 'Y':
+        msgstream << "cut y " << "on" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    case 'z':
+        msgstream << "cut z " << "off" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    case 'Z':
+        msgstream << "cut z " << "on" << endl;
+        msg = msgstream.str();
+        cerr << "client: " << msg << endl;
+        client->send(msg);
+        break;
+
+    default:
+        return;
+    }
     
     /*
-    for(int j=0; j<512; j=j+1){
+      for(int j=0; j<512; j=j+1){
       cerr << "client read: " << j << endl;
       client->receive(client->screen_buffer + j*4*512, 4*512);	//unsigned byte
-    }
+      }
     */
-    
+
     client->receive(client->screen_buffer, client->screen_size);	//unsigned byte
 
     //cin >> msg;
     //strncpy(client->screen_buffer, msg.c_str(), 512*512*4);
-	
+
     display();
     //glutPostRedisplay();
@@ -329,175 +318,173 @@
 }
 
-
-void update_rot(int delta_x, int delta_y){
-	live_rot_x += delta_x;
-	live_rot_y += delta_y;
-
-	if(live_rot_x > 360.0)
-		live_rot_x -= 360.0;	
-	else if(live_rot_x < -360.0)
-		live_rot_x += 360.0;
-
-	if(live_rot_y > 360.0)
-		live_rot_y -= 360.0;	
-	else if(live_rot_y < -360.0)
-		live_rot_y += 360.0;
-}
-
-void update_trans(int delta_x, int delta_y, int delta_z){
-        live_obj_x += delta_x*0.01;
-        live_obj_y += delta_y*0.01;
-        live_obj_z += delta_z*0.01;
-}
-
-bool test_in_box(int box_x0, int box_y0, int box_x1, int box_y1, int x, int y){
-	return (box_x0<=x && box_x1>=x && box_y0<=y && box_y1>=y);
-}
-
-void mouse(int button, int state, int x, int y){
-  if(button==GLUT_LEFT_BUTTON){
-    left_last_x = x;
-    left_last_y = y;
-
-    if(state==GLUT_DOWN){
-      left_down = true;
-      right_down = false;
-    }
-    else{
-      left_down = false;
-      right_down = true;
-    }
-  }
-  else{
-    right_last_x = x;
-    right_last_y = y;
-
-    if(state==GLUT_DOWN){
-      left_down = false;
-      right_down = true;
-    }
-    else{
-      left_down = true;
-      right_down = false;
-    }
-  }
-}
-
-void motion(int x, int y){
-  cerr << "client: motion() " << endl;
-
-  if(render_done){
-    int old_x, old_y;	
-
-    if(left_down){
-      old_x = left_last_x;
-      old_y = left_last_y;   
-    }
-    else{
-      old_x = right_last_x;
-      old_y = right_last_y;   
-    }
-
-    int delta_x = x - old_x;
-    int delta_y = y - old_y;
-
-    //more coarse event handling
-    if(abs(delta_x)<5 && abs(delta_y)<5)
-      return;
-
-    if(left_down){
-      left_last_x = x;
-      left_last_y = y;
-
-      update_rot(delta_y, delta_x);
-      std::stringstream msgstream;
-      //msgstream << "command=" << "2" << "&delta_x=" << delta_y << "&delta_y=" << delta_x << endl;
-      msgstream << "camera " << live_rot_x << " " << live_rot_y << " " << live_rot_z << " " << live_obj_z << endl;
-      std::string msg;
-      msg = msgstream.str();
-      std::cout << "client msg: " << msg <<"\n";
-      //client->send(msg);
-      client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
-    }
-    else{
-      right_last_x = x;
-      right_last_y = y;
-
-      update_trans(0, 0, delta_y);
-      std::stringstream msgstream;
-      //msgstream << "command=" << "3" << "&delta_x=" << delta_y << "&delta_y=" << delta_x << endl;
-      msgstream << "camera " << live_rot_x << " " << live_rot_y << " " << live_rot_z << " " << live_obj_z << endl;
-      std::string msg;
-      msg = msgstream.str();
-      std::cout << "client msg: " << msg <<"\n";
-      //client->send(msg);
-      client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
-    }
-
+void update_rot(int delta_x, int delta_y)
+{
+    live_rot_x += delta_x;
+    live_rot_y += delta_y;
+
+    if (live_rot_x > 360.0)
+        live_rot_x -= 360.0;	
+    else if (live_rot_x < -360.0)
+        live_rot_x += 360.0;
+
+    if (live_rot_y > 360.0)
+        live_rot_y -= 360.0;	
+    else if (live_rot_y < -360.0)
+        live_rot_y += 360.0;
+}
+
+void update_trans(int delta_x, int delta_y, int delta_z)
+{
+    live_obj_x += delta_x*0.01;
+    live_obj_y += delta_y*0.01;
+    live_obj_z += delta_z*0.01;
+}
+
+bool test_in_box(int box_x0, int box_y0, int box_x1, int box_y1, int x, int y)
+{
+    return (box_x0<=x && box_x1>=x && box_y0<=y && box_y1>=y);
+}
+
+void mouse(int button, int state, int x, int y)
+{
+    if (button == GLUT_LEFT_BUTTON) {
+        left_last_x = x;
+        left_last_y = y;
+
+        if (state == GLUT_DOWN) {
+            left_down = true;
+            right_down = false;
+        } else {
+            left_down = false;
+            right_down = true;
+        }
+    } else {
+        right_last_x = x;
+        right_last_y = y;
+
+        if (state == GLUT_DOWN) {
+            left_down = false;
+            right_down = true;
+        } else {
+            left_down = true;
+            right_down = false;
+        }
+    }
+}
+
+void motion(int x, int y)
+{
+    cerr << "client: motion() " << endl;
+
+    if (render_done) {
+        int old_x, old_y;	
+
+        if (left_down) {
+            old_x = left_last_x;
+            old_y = left_last_y;   
+        } else {
+            old_x = right_last_x;
+            old_y = right_last_y;   
+        }
+
+        int delta_x = x - old_x;
+        int delta_y = y - old_y;
+
+        //more coarse event handling
+        if (abs(delta_x)<5 && abs(delta_y)<5)
+            return;
+
+        if (left_down) {
+            left_last_x = x;
+            left_last_y = y;
+
+            update_rot(delta_y, delta_x);
+            std::stringstream msgstream;
+            //msgstream << "command=" << "2" << "&delta_x=" << delta_y << "&delta_y=" << delta_x << endl;
+            msgstream << "camera " << live_rot_x << " " << live_rot_y << " " << live_rot_z << " " << live_obj_z << endl;
+            std::string msg;
+            msg = msgstream.str();
+            std::cout << "client msg: " << msg <<"\n";
+            //client->send(msg);
+            client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
+        } else {
+            right_last_x = x;
+            right_last_y = y;
+
+            update_trans(0, 0, delta_y);
+            std::stringstream msgstream;
+            //msgstream << "command=" << "3" << "&delta_x=" << delta_y << "&delta_y=" << delta_x << endl;
+            msgstream << "camera " << live_rot_x << " " << live_rot_y << " " << live_rot_z << " " << live_obj_z << endl;
+            std::string msg;
+            msg = msgstream.str();
+            std::cout << "client msg: " << msg <<"\n";
+            //client->send(msg);
+            client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
+        }
+
+        client->receive(client->screen_buffer, client->screen_size);
+
+        /*
+          for (int j=0; j<512; j=j+4) {
+              unsigned int r,g,b,a;
+              r = client->screen_buffer[j];
+              g = client->screen_buffer[j+1];
+              b = client->screen_buffer[j+2];
+              a = client->screen_buffer[j+3];
+              //fprintf(stderr, "(%d %d %d %d) ", r,g,b,a);	//unsigned byte
+              fprintf(stderr, "(%X %X %X %X) ", r,g,b,a);	//unsigned byte
+          }
+        */
+
+        display();
+        cerr << "client: motion() done " << endl;
+    }
+}
+
+void idle()
+{
+    /*
+      struct timespec ts;
+      ts.tv_sec = 0;
+      ts.tv_nsec = 100000000;
+
+      nanosleep(&ts, 0);
+    */
+
+    //send requests
+    Event* cur = event[cur_event];
+    std::stringstream msgstream;
+    std::string msg;
+
+    switch (cur->type) {
+    case 0: //rotate
+        msgstream << "camera " << cur->parameter[0] << " " 
+                  << cur->parameter[1] << " " 
+                  << cur->parameter[2] << " " << endl;
+        break;
+
+    case 1: //move
+        msgstream << "move " << cur->parameter[0] << " " 
+                  << cur->parameter[1] << " " 
+                  << cur->parameter[2] << " " << endl;
+        break;
+
+    case 2: //other
+        msgstream << "refresh " << cur->parameter[0] << " " 
+                  << cur->parameter[1] << " " 
+                  << cur->parameter[2] << " " << endl;
+        break;
+
+    default:
+        return;
+    }
+
+    msg = msgstream.str();
+    //std::cout << "client msg: " << msg <<"\n";
+
+    //start timer
+    client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
     client->receive(client->screen_buffer, client->screen_size);
-
-    /*
-    for(int j=0; j<512; j=j+4){
-      unsigned int r,g,b,a;
-      r = client->screen_buffer[j];
-      g = client->screen_buffer[j+1];
-      b = client->screen_buffer[j+2];
-      a = client->screen_buffer[j+3];
-      //fprintf(stderr, "(%d %d %d %d) ", r,g,b,a);	//unsigned byte
-      fprintf(stderr, "(%X %X %X %X) ", r,g,b,a);	//unsigned byte
-    }
-    */
-
-    display();
-    cerr << "client: motion() done " << endl;
-  }
-}
-
-void idle(void)
-{
-/*
-    struct timespec ts;
-    ts.tv_sec = 0;
-    ts.tv_nsec = 100000000;
-
-    nanosleep(&ts, 0);
-*/
-
-  //send requests
-  Event* cur = event[cur_event];
-  std::stringstream msgstream;
-  std::string msg;
-
-  switch(cur->type){
-    case 0: //rotate
-      msgstream << "camera " << cur->parameter[0] << " " 
-		    << cur->parameter[1] << " " 
-		    << cur->parameter[2] << " " << endl;
-      break;
-
-    case 1: //move
-      msgstream << "move " << cur->parameter[0] << " " 
-		    << cur->parameter[1] << " " 
-		    << cur->parameter[2] << " " << endl;
-      break;
-
-    case 2: //other
-      msgstream << "refresh " << cur->parameter[0] << " " 
-		    << cur->parameter[1] << " " 
-		    << cur->parameter[2] << " " << endl;
-      break;
-
-    default:
-      return;
-  }
-
-  msg = msgstream.str();
-  //std::cout << "client msg: " << msg <<"\n";
-  
-  //start timer
-  client->send((char*) msg.c_str(), (int) strlen(msg.c_str()));
-  client->receive(client->screen_buffer, client->screen_size);
-  //end timer
-
+    //end timer
 }
 
@@ -512,96 +499,92 @@
 const GLfloat high_shininess[] = { 100.0f };
 
-
-void init_client(char* host, char* port, char* file){
-
-  //load the event file
-  FILE* fd = fopen(file, "r");
-  //load 5000 events
-  for(int i=0; i<5000; i++){
-    int type;
-    float param[3];
-    fscanf(fd, "%d %f %f %f\n", &type, param, param+1, param+2);
-    event[i] = new Event(type, param, 0);
-    fprintf(stderr, "%d %f %f %f\n", type, param[0], param[1], param[2]);
-  }
-  fclose(fd);
-
-  //std::string host = "localhost";
-  //hostname -i
-  //std::string host = "128.46.137.192";
+void init_client(char* host, char* port, char* file)
+{
+    //load the event file
+    FILE* fd = fopen(file, "r");
+    //load 5000 events
+    for (int i=0; i<5000; i++) {
+        int type;
+        float param[3];
+        fscanf(fd, "%d %f %f %f\n", &type, param, param+1, param+2);
+        event[i] = new Event(type, param, 0);
+        fprintf(stderr, "%d %f %f %f\n", type, param[0], param[1], param[2]);
+    }
+    fclose(fd);
+
+    //std::string host = "localhost";
+    //hostname -i
+    //std::string host = "128.46.137.192";
   
-  std::string hostname = host;
-  client = new RenderClient(hostname, atoi(port));
-
-  //point stdin stdout to socket
-  /*
-  close(0);
-  close(1);
-  dup2(client->Socket::m_sock, 0);
-  dup2(client->Socket::m_sock, 1);
-  */
+    std::string hostname = host;
+    client = new RenderClient(hostname, atoi(port));
+
+    //point stdin stdout to socket
+    /*
+      close(0);
+      close(1);
+      dup2(client->Socket::m_sock, 0);
+      dup2(client->Socket::m_sock, 1);
+    */
   
-  std::string msg1 = "hello";
-  std::string msg2 = " ";
-
-  //cout << msg1;
-  //cin >> msg2;
-
-  client->send(msg1);
-  client->receive(msg2);
+    std::string msg1 = "hello";
+    std::string msg2 = " ";
+
+    //cout << msg1;
+    //cin >> msg2;
+
+    client->send(msg1);
+    client->receive(msg2);
   
-  cerr << "client: msg received - " << msg2 << endl;
-  cerr << "connection to server established" << endl;
-}
-
-
-
-void print_gl_info(){
-  fprintf(stderr, "OpenGL vendor: %s %s\n", glGetString(GL_VENDOR), glGetString(GL_VERSION));
-  fprintf(stderr, "OpenGL renderer: %s\n", glGetString(GL_RENDERER));
-}
-
-
-void menu_cb(int entry){
-
-  std::stringstream msgstream;
-  std::string msg;
-  std::string msg2;
-  switch(entry)
-  { 
+    cerr << "client: msg received - " << msg2 << endl;
+    cerr << "connection to server established" << endl;
+}
+
+void print_gl_info()
+{
+    fprintf(stderr, "OpenGL vendor: %s %s\n", glGetString(GL_VENDOR), glGetString(GL_VERSION));
+    fprintf(stderr, "OpenGL renderer: %s\n", glGetString(GL_RENDERER));
+}
+
+void menu_cb(int entry)
+{
+    std::stringstream msgstream;
+    std::string msg;
+    std::string msg2;
+    switch (entry) { 
     case 0:
         msgstream << "command=" << "0";
-	msgstream >> msg;
-	client->send(msg);
-
-	client->receive(msg2);
+        msgstream >> msg;
+        client->send(msg);
+
+        client->receive(msg2);
 	
-	loaded = true;
-	break;
+        loaded = true;
+        break;
 
     case 1:
         msgstream << "command=" << "1";
-	msgstream >> msg;
-	client->send(msg);
-
-	client->receive(msg2);
-	break;
+        msgstream >> msg;
+        client->send(msg);
+
+        client->receive(msg2);
+        break;
 
     case 2:
         msgstream << "command=" << "2";
-	msgstream >> msg;
-	client->send(msg);
-
-	client->receive(msg2);
-	break;
-  }
+        msgstream >> msg;
+        client->send(msg);
+
+        client->receive(msg2);
+        break;
+    }
 }
 
 void help(const char *argv0)
 {
-  fprintf(stderr,
-          "Syntax: %s addr port eventfile\n",
-          argv0);
-  exit(1);
+    fprintf(stderr,
+            "Syntax: %s addr port eventfile\n",
+            argv0);
+    exit(1);
 }
 
@@ -610,5 +593,6 @@
 {
     //parameters:  hostip and port and event file
-    if(argc!=4) help(argv[0]);
+    if (argc!=4)
+        help(argv[0]);
 
     width =512; height=512;
@@ -623,8 +607,8 @@
 
     /*
-    glutCreateMenu(menu_cb);
-    glutAddMenuEntry("load data ", 0);
-    glutAddMenuEntry("toggle mode (on/off screen)", 1);
-    glutAttachMenu(GLUT_RIGHT_BUTTON);
+      glutCreateMenu(menu_cb);
+      glutAddMenuEntry("load data ", 0);
+      glutAddMenuEntry("toggle mode (on/off screen)", 1);
+      glutAttachMenu(GLUT_RIGHT_BUTTON);
     */
 
Index: trunk/packages/vizservers/nanovis/socket/RenderClient.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/RenderClient.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/RenderClient.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * RenderClient.h: server with OpenRenderer engine
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef _RENDER_CLIENT_H_
-#define _RENDER_CLIENT_H_
+#ifndef RENDER_CLIENT_H
+#define RENDER_CLIENT_H
 
 #include <iostream>
@@ -23,21 +19,23 @@
 #include "SocketException.h"
 
-class RenderClient{
-	
+class RenderClient
+{
+public:
+    RenderClient();
+    RenderClient(std::string& remote_host, int port_num);
+
+    void send(std::string& msg);
+    void receive(std::string& msg);
+
+    bool receive(char *data, int size);
+    bool send(char *data, int size);
+
+    ClientSocket *client_socket;
+    char *screen_buffer;
+    int screen_size; //units of byte
+
 private:
-	int socket_num;
-	std::string host;
-
-public:
-	ClientSocket* client_socket;
-	char* screen_buffer;
-	int screen_size; //units of byte
-	RenderClient();
-	RenderClient(std::string& remote_host, int port_num);
-	void send(std::string& msg);
-	void receive(std::string& msg);
-
-	bool receive(char* data, int size);
-	bool send(char* data, int size);
+    int socket_num;
+    std::string host;
 };
 
Index: trunk/packages/vizservers/nanovis/socket/RenderServer.cpp
===================================================================
--- trunk/packages/vizservers/nanovis/socket/RenderServer.cpp	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/RenderServer.cpp	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- *  RenderServer.cpp: server with OpenRenderer engine
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -16,83 +12,77 @@
 #include "RenderServer.h"
 
-RenderServer::RenderServer(){}
-
-RenderServer::RenderServer(int port_num){
-
-	socket_num = port_num;
-
-	//init socket server
-	std::cout << "server up and  running....\n";
-
-	try
-    	{
-      	  // Create the socket
-      	  server_socket = new ServerSocket(socket_num);
-	  //server_socket->set_non_blocking(true);
-
-        }
-  	catch ( SocketException& e )
-    	{
-      	  std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
-    	}
+RenderServer::RenderServer()
+{
 }
 
+RenderServer::RenderServer(int port_num)
+{
+    socket_num = port_num;
 
-bool  RenderServer::listen(std::string& data){
+    //init socket server
+    std::cout << "server up and  running....\n";
 
-    if(!open_socket.is_connected()){
-      if(server_socket->accept(open_socket)){
-       	fprintf(stderr, "server: connection accepted\n");
-        try
-        {
-	   //std::string data;
-	   open_socket >> data;
-	   std::cout << "server: msg received - " << data << "\n";
-
-  	   open_socket << data;
-	   return false;
-         }
-         catch ( SocketException& ) { return false;}
-      }
-    }
-    else{
-      try
-      {
-	//std::string data;
-	open_socket >> data;
-	//std::cout << "server: msg received - " << data << "\n";
-
-  	//open_socket << data;
-	return true;
-       }
-       catch ( SocketException& ) { return false;}
+    try {
+        // Create the socket
+        server_socket = new ServerSocket(socket_num);
+        //server_socket->set_non_blocking(true);
+    } catch (SocketException& e) {
+        std::cout << "Exception was caught:" << e.description() << "\nExiting.\n";
     }
 }
 
+bool  RenderServer::listen(std::string& data)
+{
+    if (!open_socket.is_connected()) {
+        if (server_socket->accept(open_socket)) {
+            fprintf(stderr, "server: connection accepted\n");
+            try {
+                //std::string data;
+                open_socket >> data;
+                std::cout << "server: msg received - " << data << "\n";
 
+                open_socket << data;
+                return false;
+            } catch (SocketException&) { 
+                return false;
+            }
+        }
+    } else {
+        try {
+            //std::string data;
+            open_socket >> data;
+            //std::cout << "server: msg received - " << data << "\n";
 
-bool  RenderServer::send(std::string& data){
-
-  if(!open_socket.is_connected())
-    return false;
-
-  try
-  {
-    open_socket << data;
-    return true;
-  }
-  catch ( SocketException& ) { return false;}
+            //open_socket << data;
+            return true;
+        } catch (SocketException&) {
+            return false;
+        }
+    }
 }
 
+bool RenderServer::send(std::string& data)
+{
+    if (!open_socket.is_connected())
+        return false;
 
-bool RenderServer::send(char* s, int size){
-  if(!open_socket.is_connected())
-    return false;
+    try {
+        open_socket << data;
+        return true;
+    } catch (SocketException&) {
+        return false;
+    }
+}
 
-  try
-  {
-    open_socket.send(s, size);
-    return true;
-  }
-  catch ( SocketException& ) { return false;}
+bool RenderServer::send(char* s, int size)
+{
+    if (!open_socket.is_connected())
+        return false;
+
+    try {
+        open_socket.send(s, size);
+        return true;
+    } catch (SocketException&) {
+        return false;
+    }
 }
Index: trunk/packages/vizservers/nanovis/socket/RenderServer.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/RenderServer.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/RenderServer.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * RenderServer.h: server with OpenRenderer engine
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef _RENDER_SERVER_H_
-#define _RENDER_SERVER_H_
+#ifndef RENDER_SERVER_H
+#define RENDER_SERVER_H
 
 #include <string>
@@ -22,17 +18,18 @@
 #include "SocketException.h"
 
-class RenderServer{
-	
+class RenderServer
+{
+public:
+    RenderServer();
+    RenderServer(int port_num);
+
+    bool listen(std::string& data);
+    bool send(std::string& data);
+    bool send(char* data, int size); //send raw bytes
+
 private:
-	ServerSocket* server_socket;
-	ServerSocket open_socket;
-	int socket_num;
-
-public:
-	RenderServer();
-	RenderServer(int port_num);
-	bool listen(std::string& data);
-	bool send(std::string& data);
-	bool send(char* data, int size); //send raw bytes
+    ServerSocket *server_socket;
+    ServerSocket open_socket;
+    int socket_num;
 };
 
Index: trunk/packages/vizservers/nanovis/socket/ServerSocket.cpp
===================================================================
--- trunk/packages/vizservers/nanovis/socket/ServerSocket.cpp	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/ServerSocket.cpp	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Implementation of the ServerSocket class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -17,99 +13,90 @@
 #include "SocketException.h"
 
-ServerSocket::ServerSocket ( int port )
+ServerSocket::ServerSocket(int port)
 {
-  connected = false;
-  if ( ! Socket::create() )
-    {
-      throw SocketException ( "Could not create server socket." );
+    connected = false;
+    if (!Socket::create()) {
+        throw SocketException("Could not create server socket.");
     }
 
-  if ( ! Socket::bind ( port ) )
-    {
-      throw SocketException ( "Could not bind to port." );
+    if (!Socket::bind(port)) {
+        throw SocketException("Could not bind to port.");
     }
 
-  if ( ! Socket::listen() )
-    {
-      throw SocketException ( "Could not listen to socket." );
+    if (!Socket::listen()) {
+        throw SocketException("Could not listen to socket.");
     }
-
 }
 
 ServerSocket::~ServerSocket()
 {
-  connected = false;
+    connected = false;
 }
 
-
-const ServerSocket& ServerSocket::operator << ( const std::string& s ) const
+const ServerSocket& ServerSocket::operator <<(const std::string& s) const
 {
-  if ( ! Socket::send ( s ) )
-    {
-      throw SocketException ( "Could not write to socket." );
+    if (!Socket::send(s)) {
+        throw SocketException("Could not write to socket.");
     }
 
-  return *this;
-
+    return *this;
 }
 
-
-const ServerSocket& ServerSocket::operator >> ( std::string& s ) const
+const ServerSocket& ServerSocket::operator >>(std::string& s) const
 {
-  if ( ! Socket::recv ( s ) )
-    {
-      throw SocketException ( "Could not read from socket." );
+    if (!Socket::recv(s)) {
+        throw SocketException("Could not read from socket.");
     }
 
-  return *this;
+    return *this;
 }
 
-bool ServerSocket::send (char* s, int size) const
+bool ServerSocket::send(char* s, int size) const
 {
-  //printf("ServerSocket::send: 0\n");
-  bool ret = Socket::send (s, size);
-  //printf("ServerSocket::send: 1\n");
-  if (!ret)
-    {
-  //printf("ServerSocket::send: 2\n");
-      throw SocketException ( "Could not write to socket." );
+    //printf("ServerSocket::send: 0\n");
+    bool ret = Socket::send(s, size);
+    //printf("ServerSocket::send: 1\n");
+    if (!ret) {
+        //printf("ServerSocket::send: 2\n");
+        throw SocketException("Could not write to socket.");
     }
 
-  return ret;
+    return ret;
 }
 
-int ServerSocket::recv ( char* s, int size) const
+int ServerSocket::recv(char* s, int size) const
 {
-  bool ret = Socket::recv (s, size);
-  if (!ret)
-    {
-      throw SocketException ( "Could not read from socket." );
+    bool ret = Socket::recv(s, size);
+    if (!ret) {
+        throw SocketException("Could not read from socket.");
     }
 
-  return ret;
+    return ret;
 }
 
-bool ServerSocket::accept ( ServerSocket& sock )
+bool ServerSocket::accept(ServerSocket& sock)
 {
-/*
-  if ( ! Socket::accept ( sock ) )
-    {
-      throw SocketException ( "Could not accept socket." );
-    }
-*/
-   bool ret =  Socket::accept( sock );
-   sock.set_connected(ret);
-   return ret;
+    /*
+      if (!Socket::accept(sock)) {
+          throw SocketException("Could not accept socket.");
+      }
+    */
+    bool ret =  Socket::accept(sock);
+    sock.set_connected(ret);
+    return ret;
 }
 
-void ServerSocket::set_non_blocking(bool val){
-	Socket::set_non_blocking(val);
+void ServerSocket::set_non_blocking(bool val)
+{
+    Socket::set_non_blocking(val);
 }
 
-bool ServerSocket::is_connected(){
-	return connected;
+bool ServerSocket::is_connected()
+{
+    return connected;
 }
 
-bool ServerSocket::set_connected(bool val){
-	return connected = val;
+bool ServerSocket::set_connected(bool val)
+{
+    return connected = val;
 }
Index: trunk/packages/vizservers/nanovis/socket/ServerSocket.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/ServerSocket.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/ServerSocket.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Definition of the ServerSocket class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef ServerSocket_class
-#define ServerSocket_class
+#ifndef SERVERSOCKET_H
+#define SERVERSOCKET_H
 
 #include "Socket.h"
@@ -21,26 +17,25 @@
 class ServerSocket : private Socket
 {
- private:
-  bool connected;
+public:
+    ServerSocket(int port);
+    ServerSocket()
+    {}
+    virtual ~ServerSocket();
 
- public:
+    const ServerSocket& operator <<(const std::string&) const;
+    const ServerSocket& operator >>(std::string&) const;
 
-  ServerSocket ( int port );
-  ServerSocket (){};
-  virtual ~ServerSocket();
+    bool send(char* s, int size) const;
+    int recv(char* s, int size) const;
 
-  const ServerSocket& operator << ( const std::string& ) const;
-  const ServerSocket& operator >> ( std::string& ) const;
+    bool accept(ServerSocket&);
 
-  bool send(char* s, int size) const;
-  int recv( char* s, int size) const;
+    void set_non_blocking(bool val);
+    bool is_connected();
+    bool set_connected(bool val);
 
-  bool accept ( ServerSocket& );
-
-  void set_non_blocking(bool val);
-  bool is_connected();
-  bool set_connected(bool val);
+private:
+    bool connected;
 };
 
-
 #endif
Index: trunk/packages/vizservers/nanovis/socket/Socket.cpp
===================================================================
--- trunk/packages/vizservers/nanovis/socket/Socket.cpp	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/Socket.cpp	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Implementation of the Socket class.
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -23,15 +19,16 @@
 ssize_t readn(int fd, void *vptr, size_t n) ;
 
-void error(int status, int err, const char *fmt, ... ){
-  va_list ap;
-  va_start(ap, fmt);
-  //fprintf(stderr, "%s: ", program_name);
-  vfprintf(stderr, fmt, ap);
-  va_end(ap);
-
-  if(err)
-    fprintf(stderr, ":%s (%d)\n", strerror(err), err);
-  if(status)
-    exit(status);
+void error(int status, int err, const char *fmt, ... )
+{
+    va_list ap;
+    va_start(ap, fmt);
+    //fprintf(stderr, "%s: ", program_name);
+    vfprintf(stderr, fmt, ap);
+    va_end(ap);
+
+    if (err)
+        fprintf(stderr, ":%s (%d)\n", strerror(err), err);
+    if (status)
+        exit(status);
 }
 
@@ -43,8 +40,8 @@
     char *endptr;
     short port;
-    
+
     bzero(sap, sizeof(*sap));
     sap->sin_family = AF_INET;
-    
+
     if (hname!=NULL) {
 	if (!inet_aton(hname, &sap->sin_addr)) {
@@ -71,309 +68,252 @@
 void parse_GET_string(char *_str, char keys[256][256], char values[256][256], int *count)
 {
-  char str[1024];
-  strcpy(str, _str);
-  char * pch_amp;
-
-  //printf ("Splitting string \"%s\" in tokens:\n",str);
-  pch_amp = strtok (str,"&");
-  //return;
-  int k=0;
-  while (pch_amp != NULL)
-  {
-    char keyval[128];
-    strcpy(keyval, pch_amp);
+    char str[1024];
+    strcpy(str, _str);
+    char * pch_amp;
+
+    //printf ("Splitting string \"%s\" in tokens:\n",str);
+    pch_amp = strtok (str,"&");
+    //return;
+    int k=0;
+    while (pch_amp != NULL) {
+        char keyval[128];
+        strcpy(keyval, pch_amp);
    
-    char *valptr = strchr(keyval, '=');
+        char *valptr = strchr(keyval, '=');
    
-    if (valptr!=NULL)
-    {
-        *valptr='\0';
-    valptr++;
+        if (valptr!=NULL) {
+            *valptr='\0';
+            valptr++;
     
-        strcpy(keys[k], keyval);
-        strcpy(values[k], valptr);
-    }
+            strcpy(keys[k], keyval);
+            strcpy(values[k], valptr);
+        } else {
+            strcpy(keys[k], keyval);
+            strcpy(values[k], "");
+        }
+        //printf("Key - :%s:, Value - :%s:\n", keys[k], values[k]);
+        pch_amp = strtok (NULL, "&");
+        k++;
+    }
+    *count = k;
+}
+
+Socket::Socket() :
+    m_sock(-1)
+{
+    memset(&m_addr, 0, sizeof(m_addr));
+}
+
+Socket::~Socket()
+{
+    if (is_valid())
+        ::close(m_sock);
+}
+
+bool Socket::create()
+{
+    m_sock = socket(AF_INET, SOCK_STREAM, 0);
+
+    if (! is_valid())
+        return false;
+
+    // TIME_WAIT - argh
+    int on = 1;
+    if (setsockopt(m_sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)) == -1)
+        return false;
+    return true;
+}
+
+bool Socket::bind(const int port)
+{
+    if (! is_valid()) {
+        return false;
+    }
+
+    m_addr.sin_family = AF_INET;
+    m_addr.sin_addr.s_addr = INADDR_ANY;
+    m_addr.sin_port = htons(port);
+
+    int bind_return = ::bind(m_sock, (struct sockaddr *)&m_addr, sizeof(m_addr));
+
+    if (bind_return == -1) {
+        return false;
+    }
+
+    return true;
+}
+
+bool Socket::listen() const
+{
+    if (!is_valid()) {
+        return false;
+    }
+
+    //printf("socket:listen:1\n");
+    //fflush(stdout);
+    int listen_return = ::listen(m_sock, MAXCONNECTIONS);
+    //printf("socket:listen:2\n");
+    //fflush(stdout);
+
+    if (listen_return == -1) {
+        return false;
+    }
+
+    return true;
+}
+
+bool Socket::accept(Socket& new_socket) const
+{
+    int addr_length = sizeof(m_addr);
+    new_socket.m_sock = ::accept(m_sock, (sockaddr *)&m_addr, (socklen_t *)&addr_length);
+
+    if (new_socket.m_sock <= 0)
+        return false;
     else
-    {
-        strcpy(keys[k], keyval);
-        strcpy(values[k], "");
-    }
-    //printf("Key - :%s:, Value - :%s:\n", keys[k], values[k]);
-    pch_amp = strtok (NULL, "&");
-    k++;
-  }
-  *count = k;
-}
-
-
-
-Socket::Socket() :
-  m_sock ( -1 )
-{
-
-  memset ( &m_addr,
-	   0,
-	   sizeof ( m_addr ) );
-
-}
-
-Socket::~Socket()
-{
-  if ( is_valid() )
-    ::close ( m_sock );
-}
-
-bool Socket::create()
-{
-  m_sock = socket ( AF_INET,
-		    SOCK_STREAM,
-		    0 );
-
-  if ( ! is_valid() )
-    return false;
-
-
-  // TIME_WAIT - argh
-  int on = 1;
-  if ( setsockopt ( m_sock, SOL_SOCKET, SO_REUSEADDR, ( const char* ) &on, sizeof ( on ) ) == -1 )
-    return false;
-
-
-  return true;
-
-}
-
-
-
-bool Socket::bind ( const int port )
-{
-
-  if ( ! is_valid() )
-    {
-      return false;
-    }
-
-  m_addr.sin_family = AF_INET;
-  m_addr.sin_addr.s_addr = INADDR_ANY;
-  m_addr.sin_port = htons ( port );
-
-  int bind_return = ::bind ( m_sock,
-			     ( struct sockaddr * ) &m_addr,
-			     sizeof ( m_addr ) );
-
-
-  if ( bind_return == -1 )
-    {
-      return false;
-    }
-
-  return true;
-}
-
-
-bool Socket::listen() const
-{
-  if ( ! is_valid() )
-    {
-      return false;
-    }
-
-  //printf("socket:listen:1\n");
-  //fflush(stdout);
-  int listen_return = ::listen ( m_sock, MAXCONNECTIONS );
-  //printf("socket:listen:2\n");
-  //fflush(stdout);
-
-
-  if ( listen_return == -1 )
-    {
-      return false;
-    }
-
-  return true;
-}
-
-
-bool Socket::accept ( Socket& new_socket ) const
-{
-  int addr_length = sizeof ( m_addr );
-  new_socket.m_sock = ::accept ( m_sock, ( sockaddr * ) &m_addr, ( socklen_t * ) &addr_length );
-
-  if ( new_socket.m_sock <= 0 )
-    return false;
-  else
-    return true;
-}
-
-
-bool Socket::send ( const std::string s ) const
-{
-  int status = ::send ( m_sock, s.c_str(), s.size(), MSG_NOSIGNAL );
-  if ( status == -1 )
-    {
-      return false;
-    }
-  else
-    {
-      return true;
-    }
-}
-
-
-bool Socket::send (char* s, int size) const
-{
-  //int status = ::send ( m_sock, s, size, MSG_NOSIGNAL );
-
-  int status = writen(m_sock, s, size);
-  if ( status == -1 )
-    {
-      return false;
-    }
-  else
-    {
-      return true;
-    }
-}
-
-
-int Socket::recv ( std::string& s ) const
-{
-  char buf [ MAXRECV + 1 ];
-
-  s = "";
-
-  memset ( buf, 0, MAXRECV + 1 );
-  int status = ::recv ( m_sock, buf, MAXRECV, 0 );
-
-  if ( status == -1 )
-    {
-      std::cout << "status == -1   errno == " << errno << "  in Socket::recv\n";
-      return 0;
-    }
-  else if ( status == 0 )
-    {
-      return 0;
-    }
-  else
-    {
-      s = buf;
-      return status;
-    }
-}
-
-
-int Socket::recv (char* s, int size) const
-{
-
-  //int status = ::recv ( m_sock, s, size, 0 );
-  int status = readn( m_sock, s, size);
-
-  if ( status == -1 )
-    {
-      std::cout << "status == -1   errno == " << errno << "  in Socket::recv\n";
-      return 0;
-    }
-  else if ( status == 0 )
-    {
-      return 0;
-    }
-  else
-    {
-      return status;
-    }
-}
-
-
-bool Socket::connect ( const std::string host, const int port )
-{
-  if ( ! is_valid() ) return false;
-
-  m_addr.sin_family = AF_INET;
-  m_addr.sin_port = htons ( port );
-
-  int status = inet_pton ( AF_INET, host.c_str(), &m_addr.sin_addr );
-
-  if ( errno == EAFNOSUPPORT ) return false;
-
-  status = ::connect ( m_sock, ( sockaddr * ) &m_addr, sizeof ( m_addr ) );
-
-  if ( status == 0 )
-    return true;
-  else
-    return false;
-}
-
-void Socket::set_non_blocking ( const bool b )
-{
-
-  int opts;
-
-  opts = fcntl ( m_sock,
-		 F_GETFL );
-
-  if ( opts < 0 )
-    {
-      return;
-    }
-
-  if ( b )
-    opts = ( opts | O_NONBLOCK );
-  else
-    opts = ( opts & ~O_NONBLOCK );
-
-  fcntl ( m_sock,
-	  F_SETFL,opts );
-
+        return true;
+}
+
+bool Socket::send(const std::string s) const
+{
+    int status = ::send(m_sock, s.c_str(), s.size(), MSG_NOSIGNAL);
+    if (status == -1) {
+        return false;
+    } else {
+        return true;
+    }
+}
+
+bool Socket::send(char* s, int size) const
+{
+    //int status = ::send (m_sock, s, size, MSG_NOSIGNAL);
+
+    int status = writen(m_sock, s, size);
+    if (status == -1) {
+        return false;
+    } else {
+        return true;
+    }
+}
+
+int Socket::recv(std::string& s) const
+{
+    char buf[MAXRECV + 1];
+
+    s = "";
+
+    memset(buf, 0, MAXRECV + 1);
+    int status = ::recv(m_sock, buf, MAXRECV, 0);
+
+    if (status == -1) {
+        std::cout << "status == -1   errno == " << errno << "  in Socket::recv\n";
+        return 0;
+    } else if (status == 0) {
+        return 0;
+    } else {
+        s = buf;
+        return status;
+    }
+}
+
+int Socket::recv(char* s, int size) const
+{
+    //int status = ::recv ( m_sock, s, size, 0 );
+    int status = readn(m_sock, s, size);
+
+    if (status == -1) {
+        std::cout << "status == -1   errno == " << errno << "  in Socket::recv\n";
+        return 0;
+    } else if (status == 0) {
+        return 0;
+    } else {
+        return status;
+    }
+}
+
+bool Socket::connect(const std::string host, const int port)
+{
+    if (!is_valid()) return false;
+
+    m_addr.sin_family = AF_INET;
+    m_addr.sin_port = htons(port);
+
+    int status = inet_pton(AF_INET, host.c_str(), &m_addr.sin_addr);
+
+    if (errno == EAFNOSUPPORT)
+        return false;
+
+    status = ::connect(m_sock, (sockaddr *)&m_addr, sizeof(m_addr));
+
+    if (status == 0)
+        return true;
+    else
+        return false;
+}
+
+void Socket::set_non_blocking(const bool b)
+{
+    int opts;
+
+    opts = fcntl(m_sock, F_GETFL);
+
+    if (opts < 0) {
+        return;
+    }
+
+    if (b)
+        opts = (opts | O_NONBLOCK);
+    else
+        opts = (opts & ~O_NONBLOCK);
+
+    fcntl(m_sock, F_SETFL, opts);
 }
 
 ssize_t readn(int fd, void *vptr, size_t n) 
 {
-  size_t nleft;
-  ssize_t nread;
-  char* ptr;
-
-  ptr = (char*) vptr;
-  nleft = n;
-
-  while(nleft > 0){
-    if((nread=read(fd, ptr, nleft))<0){
-      if(errno==EINTR)
-	nread = 0;
-      else
-	return(-1);
-    }
-    else if(nread==0){
-      fprintf(stderr, "socket::readn  nread==0\n");
-      break;
-    }
-
-    nleft -= nread;
-    ptr += nread;
-  }
-
-  return (n-nleft);	//return n>=0
-}
-
+    size_t nleft;
+    ssize_t nread;
+    char* ptr;
+
+    ptr = (char*)vptr;
+    nleft = n;
+
+    while (nleft > 0) {
+        if ((nread=read(fd, ptr, nleft))<0) {
+            if (errno==EINTR)
+                nread = 0;
+            else
+                return(-1);
+        } else if (nread==0) {
+            fprintf(stderr, "socket::readn  nread==0\n");
+            break;
+        }
+
+        nleft -= nread;
+        ptr += nread;
+    }
+
+    return (n-nleft);	//return n>=0
+}
 
 ssize_t writen(int fd, void *vptr, size_t n) 
 {
-  size_t nleft;
-  ssize_t nwritten;
-  const char* ptr;
-
-  ptr = (char*) vptr;
-  nleft = n;
-
-  while(nleft > 0){
-    if((nwritten=write(fd, ptr, nleft))<=0){
-      if(errno==EINTR)
-	nwritten = 0;
-      else
-	return(-1);
-    }
-    nleft -= nwritten;
-    ptr += nwritten;
-  }
-
-  return (n);
-}
+    size_t nleft;
+    ssize_t nwritten;
+    const char* ptr;
+
+    ptr = (char*)vptr;
+    nleft = n;
+
+    while (nleft > 0) {
+        if ((nwritten=write(fd, ptr, nleft))<=0) {
+            if (errno==EINTR)
+                nwritten = 0;
+            else
+                return(-1);
+        }
+        nleft -= nwritten;
+        ptr += nwritten;
+    }
+
+    return (n);
+}
Index: trunk/packages/vizservers/nanovis/socket/Socket.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/Socket.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/Socket.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * Definition of the Socket class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef _SOCKET_H_ 
-#define _SOCKET_H_ 
+#ifndef SOCKET_H 
+#define SOCKET_H 
 
 #include <errno.h>
@@ -29,5 +25,4 @@
 #include <arpa/inet.h>
 #include <iostream>
-
 
 const int MAXHOSTNAME = 200;
@@ -46,31 +41,33 @@
 class Socket
 {
- public:
-  Socket();
-  virtual ~Socket();
+public:
+    Socket();
+    virtual ~Socket();
 
-  // Server initialization
-  bool create();
-  bool bind ( const int port );
-  bool listen() const;
-  bool accept ( Socket& ) const;
+    // Server initialization
+    bool create();
+    bool bind(const int port);
+    bool listen() const;
+    bool accept(Socket&) const;
 
-  // Client initialization
-  bool connect ( const std::string host, const int port );
+    // Client initialization
+    bool connect(const std::string host, const int port);
 
-  // Data Transimission
-  bool send ( const std::string ) const;
-  bool send (char* s, int size) const;
-  int recv ( std::string& ) const;
-  int recv ( char* s, int size) const;
+    // Data Transimission
+    bool send(const std::string) const;
+    bool send(char* s, int size) const;
+    int recv(std::string&) const;
+    int recv(char* s, int size) const;
 
-  void set_non_blocking ( const bool );
+    void set_non_blocking(const bool);
 
-  bool is_valid() const { return m_sock != -1; }
+    bool is_valid() const {
+        return m_sock != -1;
+    }
 
-  int m_sock;
+    int m_sock;
 
- private:
-  sockaddr_in m_addr;
+private:
+    sockaddr_in m_addr;
 };
 
Index: trunk/packages/vizservers/nanovis/socket/SocketException.h
===================================================================
--- trunk/packages/vizservers/nanovis/socket/SocketException.h	(revision 2897)
+++ trunk/packages/vizservers/nanovis/socket/SocketException.h	(revision 2898)
@@ -1,8 +1,4 @@
 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * ----------------------------------------------------------------------
- * SocketException class
- *
- * ======================================================================
+/* ======================================================================
  *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
  *           Purdue Rendering and Perceptualization Lab (PURPL)
@@ -14,6 +10,6 @@
  * ======================================================================
  */
-#ifndef SocketException_class
-#define SocketException_class
+#ifndef SOCKETEXCEPTION_H
+#define SOCKETEXCEPTION_H
 
 #include <string>
@@ -21,14 +17,19 @@
 class SocketException
 {
- public:
-  SocketException ( std::string s ) : m_s ( s ) {};
-  ~SocketException (){};
+public:
+    SocketException (std::string s) :
+        m_s (s)
+    {}
 
-  std::string description() { return m_s; }
+    ~SocketException()
+    {}
 
- private:
+    std::string description()
+    {
+        return m_s;
+    }
 
-  std::string m_s;
-
+private:
+    std::string m_s;
 };
 
