blocxx
ServerSocket.cpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved.
3 * Copyright (C) 2004 Novell, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * - Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * - Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * - Neither the name of Vintela, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL Vintela, Inc. OR THE CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *******************************************************************************/
31 
38 #include "blocxx/BLOCXX_config.h"
39 #include "blocxx/ServerSocket.hpp"
40 #include "blocxx/Timeout.hpp"
41 
42 namespace BLOCXX_NAMESPACE
43 {
44 
47  : SelectableIFC()
48  , m_impl(new ServerSocketImpl(sslCtx))
49 {
50 }
53  : SelectableIFC()
54  , m_impl(new ServerSocketImpl(isSSL))
55 {
56 }
60  , SelectableIFC()
61  , m_impl(arg.m_impl)
62 {
63 }
65 Socket
66 ServerSocket::accept(int timeoutSecs)
67 {
68  return accept(Timeout::relative(static_cast<float>(timeoutSecs)));
69 }
71 Socket
73 {
74  return m_impl->accept(timeout);
75 }
77 void
78 ServerSocket::doListen(UInt16 port, SocketFlags::ESSLFlag isSSL, int queueSize,
79  const String& listenAddr, SocketFlags::EReuseAddrFlag reuseAddr)
80 {
81  m_impl->doListen(port, isSSL, queueSize, listenAddr, reuseAddr);
82 }
84 void
85 ServerSocket::doListen(UInt16 port, int queueSize,
86  const String& listenAddr, SocketFlags::EReuseAddrFlag reuseAddr)
87 {
88  m_impl->doListen(port, queueSize, listenAddr, reuseAddr);
89 }
91 #ifndef BLOCXX_WIN32
92 void
93 ServerSocket::doListen(const String& filename, int queueSize, bool reuseAddr)
94 {
95  m_impl->doListenUDS(filename, queueSize, reuseAddr);
96 }
97 #endif
98 
99 void
101 {
102  m_impl->close();
103 }
107 {
108  return m_impl->getLocalAddress();
109 }
113 {
114  return m_impl->getfd();
115 }
117 Select_t
119 {
120  return m_impl->getSelectObj();
121 }
122 
123 } // end namespace BLOCXX_NAMESPACE
124