1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 #ifndef ICE_TCP_ACCEPTOR_H
6 #define ICE_TCP_ACCEPTOR_H
7 
8 #include <Ice/TransceiverF.h>
9 #include <Ice/ProtocolInstanceF.h>
10 #include <Ice/Acceptor.h>
11 #include <Ice/Network.h>
12 
13 #if defined(ICE_OS_UWP)
14 #include <deque>
15 #endif
16 
17 namespace IceInternal
18 {
19 
20 class TcpEndpoint;
21 
22 class TcpAcceptor : public Acceptor, public NativeInfo
23 {
24 public:
25 
26     virtual NativeInfoPtr getNativeInfo();
27 #if defined(ICE_USE_IOCP) || defined(ICE_OS_UWP)
28     virtual AsyncInfo* getAsyncInfo(SocketOperation);
29 #endif
30 
31     virtual void close();
32     virtual EndpointIPtr listen();
33 #if defined(ICE_USE_IOCP) || defined(ICE_OS_UWP)
34     virtual void startAccept();
35     virtual void finishAccept();
36 #endif
37 
38     virtual TransceiverPtr accept();
39     virtual std::string protocol() const;
40     virtual std::string toString() const;
41     virtual std::string toDetailedString() const;
42 
43     int effectivePort() const;
44 
45 private:
46 
47     TcpAcceptor(const TcpEndpointIPtr&, const ProtocolInstancePtr&, const std::string&, int);
48     virtual ~TcpAcceptor();
49     friend class TcpEndpointI;
50 
51     TcpEndpointIPtr _endpoint;
52     const ProtocolInstancePtr _instance;
53     const Address _addr;
54 
55     int _backlog;
56 #if defined(ICE_USE_IOCP)
57     SOCKET _acceptFd;
58     int _acceptError;
59     std::vector<char> _acceptBuf;
60     AsyncInfo _info;
61 #elif defined(ICE_OS_UWP)
62     IceUtil::Mutex _mutex;
63     bool _acceptPending;
64     std::deque<Windows::Networking::Sockets::StreamSocket^> _accepted;
65 #endif
66 };
67 
68 }
69 #endif
70