ulxr_tcpip_connection.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                ulxr_tcpip_connection.h  -  tcpip connection
00003 
00004     begin                : Sun Apr 29 2002
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_tcpip_connection.h 1042 2007-07-31 11:40:09Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 #ifndef ULXR_TCPIP_CONNECTION_H
00031 #define ULXR_TCPIP_CONNECTION_H
00032 
00033 #ifndef ULXR_OMIT_TCP_STUFF
00034 
00035 #include <ulxmlrpcpp/ulxmlrpcpp.h>  // always first header
00036 
00037 #if defined(__WIN32__) || defined(_MSC_VER)
00038 #include <winsock2.h>
00039 //#include <windows.h>
00040 typedef int socklen_t;
00041 #endif
00042 
00043 #ifdef __unix__
00044 #include <netdb.h>
00045 #include <arpa/inet.h>
00046 #include <netinet/in.h>
00047 #include <sys/socket.h>
00048 #endif
00049 
00050 #include <ulxmlrpcpp/ulxr_connection.h>
00051 
00052 
00053 namespace ulxr {
00054 
00055 
00059 class ULXR_API_DECL0 TcpIpConnection : public Connection
00060 {
00061  public:
00062 
00070    TcpIpConnection(bool server, const CppString &domain, unsigned port = 80);
00071 
00077    void setProxy(long adr, unsigned port);
00078 
00084    void setProxy(const CppString &domain, unsigned port);
00085 
00092    TcpIpConnection(bool server, long adr = INADDR_ANY,  unsigned port = 0);
00093 
00096    virtual ~TcpIpConnection();
00097 
00102    virtual Connection *detach();
00103 
00106    virtual void open();
00107 
00113    virtual bool accept(int timeout = 0);
00114 
00117    virtual void close();
00118 
00124    virtual void shutdown(int mode);
00125 
00129    unsigned getPort();
00130 
00134    CppString getHostName() const;
00135 
00139    CppString getServerDomain() const;
00140 
00146    CppString getPeerName() const;
00147 
00152    void asciiToInAddr(const char *address,
00153                       struct in_addr &saddr);
00154 
00160    int abortOnClose(int bOn);
00161 
00169    void setTcpNoDelay(bool bOn);
00170 
00174    virtual CppString getInterfaceName();
00175 
00179    virtual int getLastError();
00180 
00184     bool isServerMode() const;
00185 
00189     virtual int getServerHandle();
00190 
00191  protected:
00192 
00196     struct hostent *getHostAdress(const CppString &hostname);
00197 
00201     virtual TcpIpConnection *makeClone();
00202 
00207    virtual void decrementServerRef(bool shutdown = false);
00208 
00209    class ServerSocketData;
00210 
00215    void setServerData (ServerSocketData *serv_data);
00216 
00220    ServerSocketData *getServerData () const;
00221 
00222  private:
00223 
00227    void init (unsigned port);
00228 
00232    int doTcpNoDelay();
00233 
00234  protected:
00235 
00236   TcpIpConnection(const TcpIpConnection&);
00237 
00238  private:
00239 
00240    // forbid them all due to internal pointers
00241   TcpIpConnection& operator=(const TcpIpConnection&); // empty!
00242 
00243  private:
00244 
00245    struct PImpl;
00246    PImpl *pimpl;
00247    int    noDelayOpt;
00248 };
00249 
00250 
00253 class ULXR_API_DECL0 TcpIpConnection::ServerSocketData
00254 {
00255   public:
00256 
00260     ServerSocketData(int s_no);
00261 
00264     virtual ~ServerSocketData();
00265 
00269     int getSocket() const;
00270 
00273     void close();
00274 
00280     virtual void shutdown(int mode);
00281 
00284     bool isOpen();
00285 
00288     void incRef();
00289 
00293     int decRef();
00294 
00295   private:
00296 
00297     int    count;
00298     int    socket_no;
00299 };
00300 
00301 
00302 }  // namespace ulxr
00303 
00304 
00305 #endif // ULXR_OMIT_TCP_STUFF
00306 
00307 #endif // ULXR_TCPIP_CONNECTION_H

Generated on Sun Aug 19 20:08:57 2007 for ulxmlrpcpp by  doxygen 1.5.1