11
11
// --------------------------------------------------------------------------
12
12
// This file is part of the "sockpp" C++ socket library.
13
13
//
14
- // Copyright (c) 2014-2023 Frank Pagliughi
14
+ // Copyright (c) 2014-2024 Frank Pagliughi
15
15
// All rights reserved.
16
16
//
17
17
// Redistribution and use in source and binary forms, with or without
@@ -108,7 +108,7 @@ class acceptor : public socket
108
108
* address.
109
109
* @param addr The address to which this server should be bound.
110
110
* @param queSize The listener queue size.
111
- * @param reuse A reuse option for the socket. This can be SO_REUSE_ADDR
111
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
112
112
* or SO_REUSEPORT, and is set before it tries to bind. A
113
113
* value of zero doesn;t set an option.
114
114
* @throws std::system_error
@@ -127,6 +127,19 @@ class acceptor : public socket
127
127
acceptor (const sock_address& addr, int queSize, error_code& ec) noexcept {
128
128
ec = open (addr, queSize).error ();
129
129
}
130
+ /* *
131
+ * Creates an acceptor socket and starts it listening to the specified
132
+ * address.
133
+ * @param addr The address to which this server should be bound.
134
+ * @param queSize The listener queue size.
135
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
136
+ * or SO_REUSEPORT, and is set before it tries to bind. A
137
+ * value of zero doesn;t set an option.
138
+ * @param ec The error code, on failure
139
+ */
140
+ acceptor (const sock_address& addr, int queSize, int reuse, error_code& ec) noexcept {
141
+ ec = open (addr, queSize, reuse).error ();
142
+ }
130
143
/* *
131
144
* Move constructor.
132
145
* Creates an acceptor by moving the other acceptor to this one.
@@ -163,7 +176,7 @@ class acceptor : public socket
163
176
* listening.
164
177
* @param addr The address to which this server should be bound.
165
178
* @param queSize The listener queue size.
166
- * @param reuse A reuse option for the socket. This can be SO_REUSE_ADDR
179
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
167
180
* or SO_REUSEPORT, and is set before it tries to bind. A
168
181
* value of zero doesn;t set an option.
169
182
* @return The error code on failure.
@@ -221,14 +234,26 @@ class acceptor_tmpl : public acceptor
221
234
throw std::system_error{res.error ()};
222
235
}
223
236
/* *
224
- * Creates a acceptor and starts it listening on the specified address.
237
+ * Creates an acceptor and starts it listening on the specified address.
225
238
* @param addr The TCP address on which to listen.
226
239
* @param queSize The listener queue size.
227
240
* @param ec The error code, on failure
228
241
*/
229
242
acceptor_tmpl (const addr_t & addr, int queSize, error_code& ec) noexcept {
230
243
ec = open (addr, queSize).error ();
231
244
}
245
+ /* *
246
+ * Creates a acceptor and starts it listening on the specified address.
247
+ * @param addr The TCP address on which to listen.
248
+ * @param queSize The listener queue size.
249
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
250
+ * or SO_REUSEPORT, and is set before it tries to bind. A
251
+ * value of zero doesn't set an option.
252
+ * @param ec The error code, on failure
253
+ */
254
+ acceptor_tmpl (const addr_t & addr, int queSize, int reuse, error_code& ec) noexcept {
255
+ ec = open (addr, queSize, reuse).error ();
256
+ }
232
257
/* *
233
258
* Creates a acceptor and starts it listening on the specified port.
234
259
* The acceptor binds to the specified port for any address on the local
@@ -252,6 +277,20 @@ class acceptor_tmpl : public acceptor
252
277
acceptor_tmpl (in_port_t port, int queSize, error_code& ec) noexcept {
253
278
ec = open (port, queSize).error ();
254
279
}
280
+ /* *
281
+ * Creates a acceptor and starts it listening on the specified port.
282
+ * The acceptor binds to the specified port for any address on the local
283
+ * host.
284
+ * @param port The TCP port on which to listen.
285
+ * @param queSize The listener queue size.
286
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
287
+ * or SO_REUSEPORT, and is set before it tries to bind. A
288
+ * value of zero doesn't set an option.
289
+ * @param ec The error code, on failure
290
+ */
291
+ acceptor_tmpl (in_port_t port, int queSize, int reuse, error_code& ec) noexcept {
292
+ ec = open (port, queSize, reuse).error ();
293
+ }
255
294
/* *
256
295
* Move constructor.
257
296
* Creates an acceptor by moving the other acceptor to this one.
@@ -290,7 +329,7 @@ class acceptor_tmpl : public acceptor
290
329
* listening.
291
330
* @param addr The address to which this server should be bound.
292
331
* @param queSize The listener queue size.
293
- * @param reuse A reuse option for the socket. This can be SO_REUSE_ADDR
332
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
294
333
* or SO_REUSEPORT, and is set before it tries to bind. A
295
334
* value of zero doesn;t set an option.
296
335
* @return @em true on success, @em false on error
@@ -303,7 +342,7 @@ class acceptor_tmpl : public acceptor
303
342
* listening.
304
343
* @param port The TCP port on which to listen.
305
344
* @param queSize The listener queue size.
306
- * @param reuse A reuse option for the socket. This can be SO_REUSE_ADDR
345
+ * @param reuse A reuse option for the socket. This can be SO_REUSEADDR
307
346
* or SO_REUSEPORT, and is set before it tries to bind. A
308
347
* value of zero doesn;t set an option.
309
348
* @return @em true on success, @em false on error
0 commit comments