mn_basic_ip4_endpoint.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_IP4_ENDPOINT_H__
19 #define __MINILIB_NET_BASIC_IP4_ENDPOINT_H__
20 
21 
22 #define MNNET_IPENDPOINT4_BROADCAST(PORT) mn::net::basic_ip4_endpoint(MNNET_IPV4_ADDRESS_BROADCAST, PORT)
23 #define MNNET_IPENDPOINT4_ANY(PORT) mn::net::basic_ip4_endpoint(MNNET_IPV4_ADDRESS_ANY, PORT)
24 #define MNNET_IPENDPOINT4_LOOPBACK(PORT) mn::net::basic_ip4_endpoint(MNNET_IPV4_ADDRESS_LOOPBACK, PORT)
25 #define MNNET_IPENDPOINT4_NONE(PORT) mn::net::basic_ip4_endpoint(MNNET_IPV4_ADDRESS_NONE, PORT)
26 #define MNNET_IPENDPOINT4(IP, PORT) mn::net::basic_ip4_endpoint(IP, PORT)
27 #define MNNET_IPENDPOINT4_EMPTY MNNET_IPENDPOINT4_ANY(0)
28 
29 #include "../mn_config.hpp"
30 #include "mn_basic_endpoint.hpp"
31 #include "mn_basic_ip4_address.hpp"
32 
33 namespace mn {
34  namespace net {
35 
36  class basic_ip4_endpoint : public basic_ip_endpoint<basic_ip4_address, address_family::inet_v4> {
38  public:
39  basic_ip4_endpoint(const uint16_t& port = 0) noexcept;
40  basic_ip4_endpoint(const basic_ip4_address& ip, const uint16_t& port) noexcept;
41  basic_ip4_endpoint(const basic_ip4_endpoint& pOther) noexcept;
42 
47  using base_type::get_port;
52  using base_type::get_host;
56  using base_type::set_port;
61  using base_type::is_multicast;
66  using base_type::is_loopback;
71  using base_type::get_famile;
72 
73  using base_type::operator =;
74  using base_type::operator ==;
75  using base_type::operator !=;
76 
77  using base_type::swap;
78 
83  basic_endpoint* get_copy() override;
84 
91  };
92  }
93 }
94 
95 
96 
97 #endif // __MINILIB_NET_BASIC_IP4_ENDPOINT_H__
This abstract basic class represents an endpoint/socket address.
Definition: mn_basic_endpoint.hpp:43
This class represents an internet (IP) version 6 host address.
Definition: mn_basic_ip4_address.hpp:38
Definition: mn_basic_ip4_endpoint.hpp:36
basic_ip4_endpoint(const uint16_t &port=0) noexcept
Definition: mn_basic_ip4_endpoint.cpp:27
basic_ip4_address get_ip() MN_DEPRECATED
Get the host IP address.
Definition: mn_basic_ip4_endpoint.hpp:90
basic_endpoint * get_copy() override
Get a copy from this.
Definition: mn_basic_ip4_endpoint.cpp:47
This template basic class represents an ip endpoint/socket address.
Definition: mn_basic_endpoint.hpp:59
address_family get_famile()
Get the address family of the address.
Definition: mn_basic_endpoint.hpp:90
void set_port(const uint16_t &port)
Set a port number, between 0-9999.
Definition: mn_basic_endpoint.hpp:94
uint16_t get_port()
Get the port number.
Definition: mn_basic_endpoint.hpp:80
bool is_multicast()
Is the host address a multicast address.
Definition: mn_basic_endpoint.hpp:104
virtual void swap(self_type &rhs) noexcept
Definition: mn_basic_endpoint.hpp:143
ip_type get_host()
Get the host IP address.
Definition: mn_basic_endpoint.hpp:85
bool is_loopback()
Is the host address a loopaddress.
Definition: mn_basic_endpoint.hpp:109
#define MN_DEPRECATED
Definition: mn_defines.hpp:54
Definition: mn_allocator_typetraits.hpp:25