mn_basic_ip6_socket.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2018 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef __MINILIB_NET_BASIC_IP6_SOCKET_H__
19 #define __MINILIB_NET_BASIC_IP6_SOCKET_H__
20 
21 #include "../mn_config.hpp"
22 #include "mn_basic_socket.hpp"
24 
25 #if MN_THREAD_CONFIG_NET_IPADDRESS6_ENABLE == MN_THREAD_CONFIG_YES
26 
27 namespace mn {
28  namespace net {
34  public:
38 
44  basic_ip6_socket(handle_type& hndl, basic_ip6_endpoint* endp = nullptr) noexcept;
50  basic_ip6_socket(const socket_type& type, const protocol_type& protocol) noexcept;
54  basic_ip6_socket(const basic_ip6_socket& other) noexcept;
61  basic_ip6_socket& operator=(const basic_ip6_socket& other) noexcept;
62 
63 
72  bool bind(basic_ip6_endpoint local_ep);
83  bool bind(const unsigned int& port);
94  bool bind(basic_ip6_address ip, const unsigned int& port);
95 
103  endpoint_type* get_endpoint(bool local);
108  endpoint_type* get_local() { return get_endpoint(true); }
113  endpoint_type* get_remote() { return get_endpoint(false); }
114 
121  bool get_peername(endpoint_type& endpoint);
129  bool get_peername(ipaddress_type& ipPeerAddress, uint16_t& iPeerPort);
134  virtual basic_ip_socket* get_copy() { return new basic_ip6_socket(*this); }
135 
136  virtual void swap(basic_ip6_socket& rhs) noexcept {
138  mn::swap(m_pEndPoint, rhs.m_pEndPoint);
139  }
140  protected:
145  };
146  }
147 }
148 
149 #endif // MN_THREAD_CONFIG_NET_IPADDRESS6_ENABLE
150 
151 #endif // __MINILIB_NET_BASIC_IP6_SOCKET_H__
This class represents an internet (IP) version 6 host address.
Definition: mn_basic_ip6_address.hpp:49
This class represents an IPv6 endpoint/socket address.
Definition: mn_basic_ip6_endpoint.hpp:41
This class represents an internet (IP) version 6 host socket.
Definition: mn_basic_ip6_socket.hpp:33
endpoint_type * get_local()
Get the local endpoint.
Definition: mn_basic_ip6_socket.hpp:108
virtual basic_ip_socket * get_copy()
Get a copy of this socket.
Definition: mn_basic_ip6_socket.hpp:134
virtual void swap(basic_ip6_socket &rhs) noexcept
Definition: mn_basic_ip6_socket.hpp:136
basic_ip6_socket(handle_type &hndl, basic_ip6_endpoint *endp=nullptr) noexcept
Construct the wrapper class from a given lwip socket handle and the endpoint.
Definition: mn_basic_ip6_socket.cpp:29
basic_ip6_address ipaddress_type
Definition: mn_basic_ip6_socket.hpp:37
endpoint_type * m_pEndPoint
A saved / cached copy of the endpoint on binde the socket.
Definition: mn_basic_ip6_socket.hpp:144
basic_ip6_endpoint endpoint_type
Definition: mn_basic_ip6_socket.hpp:36
typename basic_ip_socket::handle_type handle_type
Definition: mn_basic_ip6_socket.hpp:35
endpoint_type * get_endpoint(bool local)
Get the local or remote ip endpoint.
Definition: mn_basic_ip6_socket.cpp:62
bool get_peername(endpoint_type &endpoint)
Get the remote endpoint.
Definition: mn_basic_ip6_socket.cpp:160
endpoint_type * get_remote()
Get the remote endpoint.
Definition: mn_basic_ip6_socket.hpp:113
bool bind(basic_ip6_endpoint local_ep)
Bind the socket on the given endpoint (ip and port)
Definition: mn_basic_ip6_socket.cpp:91
Wrapper class around lwip implementation of a socket.
Definition: mn_basic_socket.hpp:54
virtual void swap(basic_ip_socket &rhs) noexcept
Definition: mn_basic_socket.hpp:136
int handle_type
Definition: mn_basic_socket.hpp:56
struct mn::memory::detail::ptr_difference type
protocol_type
Defines socket protoco types for creating.
Definition: mn_net_types.hpp:60
socket_type
Defines socket socket types for creating.
Definition: mn_net_types.hpp:99
Definition: mn_allocator_typetraits.hpp:25
void swap(TAssignable &a, TAssignable &b)
Definition: mn_algorithm.hpp:312