Listing 1: The client socket class

// file csocket.h
#ifndef CSOCKET_HXX
#define CSOCKET_HXX

class csocket
   {
   private:
      int clientsock;
      struct sockaddr_in sockClientAddr;
      struct hostent *lpHostEnt;
      string client_hostname;
      int client_port;
      bool client_init;
      int client_connect(void);
      int recv_data(string& buf);
      int send_data(string& buf);

   public:
      csocket();
      csocket(string& host_name, int port);
      csocket(char *host_name, int port);
      int 
      set_active(string& host_name, 
         int port_number);
      int 
      get_active(string& host_name, 
         int& port_number);
      int send_receive(string& sbuf, string& rbuf);
      int send_receive(char *sbuf, string& rbuf);
      int close_socket(void);
      bool is_init(void) 
      { return(client_init); }
   };
#endif
— End of Listing —