## root/include/csocket.h

/* [<][>][^][v][top][bottom][index][help] */

## INCLUDED FROM

    /* Definition of client socket class
       Rick Smereka, Copyright (C) 2000-2002.

       This program is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published by
       the Free Software Foundation; either version 2 of the License, or
       (at your option) any later version.

       This program is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       GNU General Public License for more details.

       You should have received a copy of the GNU General Public License
       along with this program; if not, get a copy via the Internet at
       http://gnu.org/copyleft/gpl.html or write to the Free Software
       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
       MA 02111-1307 USA

       You can contact the author via email at rsmereka@future-lab.com

       Original version for Unix and Windows 32-bit.
       Aug/2000, Rick Smereka

       Ported to Debian Linux. Nov/2002, Rick Smereka

       Added 'using namespace std'. Dec/2002, Rick Smereka */

    #ifndef CSOCKET_HXX
    #define CSOCKET_HXX

    using namespace std;

    class csocket
       {
       private:
    #ifdef OS_WIN32
          SOCKET clientsock;
          SOCKADDR_IN sockClientAddr;
          LPHOSTENT lpHostEnt;
    #endif

    #ifdef OS_UNIX
          int clientsock;
          struct sockaddr_in sockClientAddr;
          struct hostent *lpHostEnt;
    #endif

          string client_hostname;
          int client_port;
          bool client_init;

          // private member functions
          int client_connect(void);
          int recv_data(string& buf);
          int send_data(string& buf);

       public:
          // constructors
          csocket();
          csocket(string& host_name, int port);
          csocket(char *host_name, int port);

          // member fuctions
          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

/* [<][>][^][v][top][bottom][index][help] */