sockpp
Modern C++ socket library wrapper
unix_acceptor.h
Go to the documentation of this file.
1 
11 // --------------------------------------------------------------------------
12 // This file is part of the "sockpp" C++ socket library.
13 //
14 // Copyright (c) 2014-2017 Frank Pagliughi
15 // All rights reserved.
16 //
17 // Redistribution and use in source and binary forms, with or without
18 // modification, are permitted provided that the following conditions are
19 // met:
20 //
21 // 1. Redistributions of source code must retain the above copyright notice,
22 // this list of conditions and the following disclaimer.
23 //
24 // 2. Redistributions in binary form must reproduce the above copyright
25 // notice, this list of conditions and the following disclaimer in the
26 // documentation and/or other materials provided with the distribution.
27 //
28 // 3. Neither the name of the copyright holder nor the names of its
29 // contributors may be used to endorse or promote products derived from this
30 // software without specific prior written permission.
31 //
32 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
34 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
35 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
36 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 // --------------------------------------------------------------------------
44 
45 #ifndef __sockpp_unix_acceptor_h
46 #define __sockpp_unix_acceptor_h
47 
48 #include "sockpp/acceptor.h"
50 
51 namespace sockpp {
52 
54 
61 
62 class unix_acceptor : public acceptor
63 {
65  using base = acceptor;
66 
67  // Non-copyable
68  unix_acceptor(const unix_acceptor&) =delete;
69  unix_acceptor& operator=(const unix_acceptor&) =delete;
70 
71 public:
81  unix_acceptor(const unix_address& addr, int queSize=DFLT_QUE_SIZE) {
82  open(addr, queSize);
83  }
92  using base::open;
99  bool open(const unix_address& addr, int queSize=DFLT_QUE_SIZE) {
100  return base::open(addr, queSize);
101  }
108 };
109 
111 // end namespace sockpp
112 };
113 
114 #endif // __sockpp_unix_acceptor_h
115 
Class for a TCP server to accept incoming connections.
Class for creating a Unix-domain server.
Definition: unix_acceptor.h:62
unix_address address() const
Gets the local address to which we are bound.
Definition: unix_acceptor.h:88
unix_acceptor(const unix_address &addr, int queSize=DFLT_QUE_SIZE)
Creates a acceptor and starts it listening on the specified address.
Definition: unix_acceptor.h:81
sock_address_any address() const
Gets the local address to which the socket is bound.
stream_socket accept(sock_address *clientAddr=nullptr)
Accepts an incoming TCP connection and gets the address of the client.
static const int DFLT_QUE_SIZE
The default listener queue size.
Definition: acceptor.h:74
Class (typedef) for Unix-domain streaming socket.
Class that represents a UNIX domain address.
Definition: unix_address.h:65
unix_acceptor()
Creates an unconnected acceptor.
Definition: unix_acceptor.h:75
Class for creating a streaming server.
Definition: acceptor.h:63
bool open(const sock_address &addr, int queSize=DFLT_QUE_SIZE, bool reuseSock=true)
Opens the acceptor socket, binds it to the specified address, and starts listening.
acceptor()
Creates an unconnected acceptor.
Definition: acceptor.h:92
Definition: acceptor.h:51
bool open(const unix_address &addr, int queSize=DFLT_QUE_SIZE)
Opens the acceptor socket and binds it to the specified address.
Definition: unix_acceptor.h:99
Base class for socket objects.
Definition: socket.h:84
Template for creating specific stream types (IPv4, IPv6, etc).
Definition: stream_socket.h:245
unix_socket accept()
Accepts an incoming UNIX connection and gets the address of the client.
Definition: unix_acceptor.h:107