00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00042 #ifndef BLOCXX_INETSERVERSOCKETIMPL_HPP_INCLUDE_GUARD_
00043 #define BLOCXX_INETSERVERSOCKETIMPL_HPP_INCLUDE_GUARD_
00044 #include "blocxx/BLOCXX_config.h"
00045 #include "blocxx/SelectableIFC.hpp"
00046 #include "blocxx/Socket.hpp"
00047 #include "blocxx/SocketAddress.hpp"
00048 #include "blocxx/Types.hpp"
00049 #include "blocxx/File.hpp"
00050 #include "blocxx/SocketFlags.hpp"
00051 #include "blocxx/IntrusiveCountableBase.hpp"
00052 #include "blocxx/SSLCtxMgr.hpp"
00053
00054
00055
00056
00057 namespace BLOCXX_NAMESPACE
00058 {
00059
00060 class BLOCXX_COMMON_API ServerSocketImpl : public SelectableIFC
00061 {
00062 public:
00063 ServerSocketImpl(SSLServerCtxRef sslCtx);
00064 ServerSocketImpl(SocketFlags::ESSLFlag isSSL);
00065 ~ServerSocketImpl();
00066 String addrString();
00067 Socket accept(const Timeout& timeout);
00068 void close();
00069
00070
00071 SocketAddress getLocalAddress() { return m_localAddress; }
00072 SocketHandle_t getfd() const { return m_sockfd; }
00073
00074
00075
00076 void doListen(UInt16 port, SocketFlags::ESSLFlag isSSL, int queueSize=10,
00077 const String& listenAddr = SocketAddress::ALL_LOCAL_ADDRESSES,
00078 SocketFlags::EReuseAddrFlag reuseAddr = SocketFlags::E_REUSE_ADDR);
00079
00080
00081 void doListenIPv4(UInt16 port, int queueSize, const String& listenAddr);
00082 #ifdef BLOCXX_HAVE_IPV6
00083
00084 void doListenIPv6(UInt16 port, int queueSize, const String& listenAddr);
00085 #endif
00086 void doListen(UInt16 port, int queueSize=10,
00087 const String& listenAddr = SocketAddress::ALL_LOCAL_ADDRESSES,
00088 SocketFlags::EReuseAddrFlag reuseAddr = SocketFlags::E_REUSE_ADDR);
00089
00090 #ifndef BLOCXX_WIN32
00091 void doListenUDS(const String& filename, int queueSize=10,
00092 bool reuseAddr = true);
00093 #endif
00094
00095 Select_t getSelectObj() const;
00096 private:
00097 void fillAddrParms();
00098 SocketHandle_t m_sockfd;
00099
00100
00101 SocketAddress m_localAddress;
00102 bool m_isActive;
00103 ServerSocketImpl(const ServerSocketImpl& arg);
00104 ServerSocketImpl& operator=(const ServerSocketImpl& arg);
00105 SocketFlags::ESSLFlag m_isSSL;
00106
00107 #ifdef BLOCXX_WIN32
00108 #pragma warning (push)
00109 #pragma warning (disable: 4251)
00110 #endif
00111
00112 SSLServerCtxRef m_sslCtx;
00113 #if defined(BLOCXX_WIN32)
00114 #pragma warning (pop)
00115 HANDLE m_event;
00116 bool m_shuttingDown;
00117 #else
00118 File m_udsFile;
00119 #endif
00120 };
00121
00122 }
00123
00124 #endif