Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

tcprpcclient.hpp

00001 /************************************************************************************
00002  *    This file is part of the MynahSA streaming and archiving toolkit              *
00003  *    Copyright (C) 2006 Mynah-Software Ltd. All Rights Reserved.                   *
00004  *                                                                                  *
00005  *    This program is free software; you can redistribute it and/or modify          *
00006  *    it under the terms of the GNU General Public License, version 2               *
00007  *    as published by the Free Software Foundation.                                 *
00008  *                                                                                  *
00009  *    This program is distributed in the hope that it will be useful,               *
00010  *    but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00011  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00012  *    GNU General Public License for more details.                                  *
00013  *                                                                                  *
00014  *    You should have received a copy of the GNU General Public License along       *
00015  *    with this program; if not, write to the Free Software Foundation, Inc.,       *
00016  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                   *
00017  *                                                                                  *
00018  ************************************************************************************/
00019 
00020 #ifndef __tcp_rpc_client_hpp
00021 #define __tcp_rpc_client_hpp
00022 
00023 #include "iobase.hpp"
00024 
00025 #ifdef WIN32
00026 #include <windows.h>
00027 #include <winsock2.h>
00028 #else
00029 #include <netinet/in.h>
00030 #include <arpa/inet.h>
00031 #endif
00032 
00033 #include "tcparchivestream.hpp"
00034 #include "streamconstructor.hpp"
00035 
00036 #include <string>
00037 
00038 #include <mynahsa/spimpl.hpp>
00039 
00040 
00041 namespace MynahSA { 
00047   class TCPRPCClient {
00048   public:
00056     TCPRPCClient(const StreamConstructor& sc,
00057                  unsigned int ipaddress, 
00058                  unsigned int port);
00059     
00060     
00068     TCPRPCClient(const StreamConstructor& sc,
00069                  std::string machineName, 
00070                  unsigned int port);
00071     
00073     ~TCPRPCClient();
00074   
00076     SHARED_PTR<IoBase> rpc(SHARED_PTR<IoBase> req);
00077   
00079     bool is_open() const { return _isopen; }
00080   
00082     void close();
00083   
00084   
00085   private:
00087     void init(const StreamConstructor& sc,
00088               unsigned int ipaddress,
00089               unsigned int port);
00090   
00092     bool _isopen;
00093     
00095     int         _sd;
00096   
00098     SHARED_PTR<TCPArchiveStream> _stream;
00099   
00100   };
00101 };
00102 
00103 #endif