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"
40#include "blocxx/Timeout.hpp"
41
42namespace BLOCXX_NAMESPACE
43{
44
65Socket
66ServerSocket::accept(int timeoutSecs)
67{
68 return accept(Timeout::relative(static_cast<float>(timeoutSecs)));
69}
71Socket
73{
74 return m_impl->accept(timeout);
75}
77void
78ServerSocket::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}
84void
85ServerSocket::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
92void
93ServerSocket::doListen(const String& filename, int queueSize, bool reuseAddr)
94{
95 m_impl->doListenUDS(filename, queueSize, reuseAddr);
96}
97#endif
99void
101{
102 m_impl->close();
103}
107{
108 return m_impl->getLocalAddress();
109}
113{
114 return m_impl->getfd();
115}
119{
120 return m_impl->getSelectObj();
121}
122
123} // end namespace BLOCXX_NAMESPACE
124
ProcessImplRef m_impl
Definition Process.cpp:317
void doListen(UInt16 port, SocketFlags::ESSLFlag isSSL, int queueSize=10, const String &listenAddr=SocketAddress::ALL_LOCAL_ADDRESSES, SocketFlags::EReuseAddrFlag reuseAddr=SocketFlags::E_REUSE_ADDR)
Start listening on a port.
SocketAddress getLocalAddress()
Return the address of the local host.
Socket accept(int timeoutSecs=-1) BLOCXX_DEPRECATED
Accept a connection to the server socket.
ServerSocket(SSLServerCtxRef sslCtx)
Allocate a new Inet Server Socket.
void close()
Close the listen socket.
SocketHandle_t getfd() const
Get the file descriptor of the listen socket.
IntrusiveReference< ServerSocketImpl > m_impl
This String class is an abstract data type that represents as NULL terminated string of characters.
Definition String.hpp:67
A timeout can be absolute, which means that it will happen at the specified DateTime.
Definition Timeout.hpp:56
static Timeout relative(float seconds)
Definition Timeout.cpp:58
Taken from RFC 1321.