00001 00014 // TcpConnectionServer.h -- interface for the TcpConnectionServer class 00015 00016 #ifndef TCPCONNECTIONSERVER_H_ 00017 #define TCPCONNECTIONSERVER_H_ 00018 00019 #ifdef _MSC_VER 00020 #pragma once 00021 #endif // MSVC 00022 00023 #include "Socket.h" 00024 class TcpSocket; 00025 00026 00028 // TcpConnectionServer 00029 00030 // Accepts incoming TCP connections on a particular address 00031 00032 class TcpConnectionServer : public Socket 00033 { 00034 public: 00035 // Enumerator. 00036 enum { max_backlog = 5 }; 00037 00038 // Construct and bind to the SocketAddress 00039 // backlog is the maximum length of the queue of pending connections 00040 TcpConnectionServer(const SocketAddress& address,int backlog = max_backlog); 00041 00042 // Construct from native OS socket descriptor 00043 TcpConnectionServer(SOCKET descriptor); 00044 00045 // Places socket state to listen for incoming connections. 00046 // backlog is the maximum length of the queue of pending connections 00047 void listen(int backlog = max_backlog); 00048 00049 // Permits an incoming connection attempt on a socket 00050 bool accept( TcpSocket& socket ); 00051 00052 protected: 00053 // Hide the copy constructor and assignment operator 00054 TcpConnectionServer( const TcpConnectionServer& ); 00055 void operator=( const TcpConnectionServer& ); 00056 }; 00057 00058 00059 #endif // TCPCONNECTIONSERVER_H_