1 /*
2 * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2.0,
6 * as published by the Free Software Foundation.
7 *
8 * This program is also distributed with certain software (including
9 * but not limited to OpenSSL) that is licensed under separate terms,
10 * as designated in a particular file or component or in included license
11 * documentation. The authors of MySQL hereby grant you an additional
12 * permission to link the program and your derivative works with the
13 * separately licensed software that they have included with MySQL.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License, version 2.0, for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 * 02110-1301 USA
24 */
25
26 #include "xpl_listener_factory.h"
27 #include "io/xpl_listener_tcp.h"
28 #include "io/xpl_listener_unix_socket.h"
29 #include "ngs_common/operations_factory.h"
30
31
32 namespace xpl {
33
Listener_factory()34 Listener_factory::Listener_factory() {
35 m_operations_factory = ngs::make_shared<ngs::Operations_factory>();
36 }
37
create_unix_socket_listener(const std::string & unix_socket_path,ngs::Socket_events_interface & event,const uint32 backlog)38 ngs::Listener_interface_ptr Listener_factory::create_unix_socket_listener(
39 const std::string &unix_socket_path,
40 ngs::Socket_events_interface &event,
41 const uint32 backlog) {
42 return ngs::Listener_interface_ptr(
43 ngs::allocate_object<Listener_unix_socket>(
44 m_operations_factory,
45 unix_socket_path,
46 ngs::ref(event),
47 backlog));
48 }
49
create_tcp_socket_listener(std::string & bind_address,const unsigned short port,const uint32 port_open_timeout,ngs::Socket_events_interface & event,const uint32 backlog)50 ngs::Listener_interface_ptr Listener_factory::create_tcp_socket_listener(
51 std::string &bind_address,
52 const unsigned short port,
53 const uint32 port_open_timeout,
54 ngs::Socket_events_interface &event,
55 const uint32 backlog) {
56 return ngs::Listener_interface_ptr(
57 ngs::allocate_object<Listener_tcp>(m_operations_factory,
58 ngs::ref(bind_address),
59 port,
60 port_open_timeout,
61 ngs::ref(event),
62 backlog));
63 }
64
65 } // namespace xpl
66