mn_basic_dgram_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_BASIC_DGRAM_SOCKET_H_
19 #define _MINILIB_BASIC_DGRAM_SOCKET_H_
20 
21 #include "../mn_config.hpp"
22 #include "mn_basic_socket.hpp"
23 #include "mn_basic_ip4_socket.hpp"
24 #include "mn_basic_ip6_socket.hpp"
25 
26 namespace mn {
27  namespace net {
33  public:
36 
40 
46 
56  int send_to(char* buffer, int size, endpoint_type& ep, const socket_flags& socketFlags = socket_flags::none)
57  { return send_to(buffer, 0, size, socketFlags, ep); }
58 
68  int recive_from(char* buffer, int size, endpoint_type* ep, const socket_flags& socketFlags = socket_flags::none)
69  { return recive_from(buffer, 0, size, socketFlags, ep); }
70 
80  int recive_from(char* buffer, int offset, int size, const socket_flags& socketFlags, endpoint_type* ep);
81 
92  int send_to(char* buffer, int offset, int size, const socket_flags& socketFlags, endpoint_type& ep);
93 
94 
95  protected:
97  : base_type(hndl, endp) { }
99  : base_type(socket_type::dgram, protocol) { }
100  private:
101  //ipaddress_type m_ipMultiCast;
102  };
103 #if LWIP_UDP && LWIP_UDPLITE
108  class basic_dgramlite_ip_socket : public basic_dgram_ip_socket {
109  public:
110  basic_dgramlite_ip_socket() : basic_dgram_ip_socket(protocol_type::udp_lite) { }
111 
112 
113  };
114 #endif
115 
116 #if MN_THREAD_CONFIG_NET_IPADDRESS6_ENABLE == MN_THREAD_CONFIG_YES
122  public:
125 
129 
132 
142  int send_to(char* buffer, int size, endpoint_type* ep, socket_flags socketFlags = socket_flags::none)
143  { return send_to(buffer, 0, size, socketFlags, ep); }
144 
154  int recive_from(char* buffer, int size, endpoint_type* ep, socket_flags socketFlags = socket_flags::none)
155  { return recive_from(buffer, 0, size, socketFlags, ep); }
156 
166  int recive_from(char* buffer, int offset, int size, socket_flags socketFlags, endpoint_type* ep);
177  int send_to(char* buffer, int offset, int size, socket_flags socketFlags, endpoint_type* ep);
178 
179 
180  protected:
182  : base_type(hndl, endp) { }
184  : base_type(socket_type::dgram, protocol) { }
185  };
186  #if LWIP_UDP && LWIP_UDPLITE
191  class basic_dgramlite_ip6_socket : public basic_dgram_ip6_socket {
192  public:
193  basic_dgramlite_ip6_socket() : basic_dgram_ip6_socket(protocol_type::udp_lite) { }
194 
195 
196  };
197  #endif // LWIP_UDP
198 
199 
200 #endif
201  }
202 }
203 
204 #endif // _MINILIB_BASIC_DGRAM_SOCKET_H_
A buffer class that allocates a buffer of a given type and size.
Definition: mn_buffer.hpp:37
Basic dram socket class.
Definition: mn_basic_dgram_socket.hpp:121
typename base_type::endpoint_type endpoint_type
Definition: mn_basic_dgram_socket.hpp:126
basic_dgram_ip6_socket(handle_type &hndl, endpoint_type *endp=nullptr)
Definition: mn_basic_dgram_socket.hpp:181
typename base_type::handle_type handle_type
Definition: mn_basic_dgram_socket.hpp:128
int send_to(char *buffer, int size, endpoint_type *ep, socket_flags socketFlags=socket_flags::none)
send a buffer of data to the given enpoint
Definition: mn_basic_dgram_socket.hpp:142
int recive_from(char *buffer, int size, endpoint_type *ep, socket_flags socketFlags=socket_flags::none)
recive a buffer of data
Definition: mn_basic_dgram_socket.hpp:154
basic_dgram_ip6_socket(const protocol_type &protocol)
Definition: mn_basic_dgram_socket.hpp:183
typename base_type::ipaddress_type ipaddress_type
Definition: mn_basic_dgram_socket.hpp:127
basic_dgram_ip6_socket()
Definition: mn_basic_dgram_socket.hpp:130
Basic dram socket class.
Definition: mn_basic_dgram_socket.hpp:32
basic_dgram_ip_socket(const protocol_type &protocol)
Definition: mn_basic_dgram_socket.hpp:98
int send_to(char *buffer, int size, endpoint_type &ep, const socket_flags &socketFlags=socket_flags::none)
send a buffer of data to the given enpoint
Definition: mn_basic_dgram_socket.hpp:56
typename base_type::ipaddress_type ipaddress_type
Definition: mn_basic_dgram_socket.hpp:38
typename base_type::handle_type handle_type
Definition: mn_basic_dgram_socket.hpp:39
typename base_type::endpoint_type endpoint_type
Definition: mn_basic_dgram_socket.hpp:37
basic_dgram_ip_socket()
Construt.
Definition: mn_basic_dgram_socket.hpp:44
basic_dgram_ip_socket(handle_type &hndl, endpoint_type *endp=nullptr)
Definition: mn_basic_dgram_socket.hpp:96
int recive_from(char *buffer, int size, endpoint_type *ep, const socket_flags &socketFlags=socket_flags::none)
recive a buffer of data
Definition: mn_basic_dgram_socket.hpp:68
This class represents an internet (IP) version 4 host socket.
Definition: mn_basic_ip4_socket.hpp:31
basic_ip4_socket(handle_type &hndl, endpoint_type *endp=nullptr) noexcept
Construct the wrapper class from a given lwip socket handle and the endpoint.
Definition: mn_basic_ip4_socket.cpp:27
basic_ip4_endpoint endpoint_type
Definition: mn_basic_ip4_socket.hpp:34
basic_ip4_address ipaddress_type
Definition: mn_basic_ip4_socket.hpp:35
typename basic_ip_socket::handle_type handle_type
Definition: mn_basic_ip4_socket.hpp:33
This class represents an internet (IP) version 6 host socket.
Definition: mn_basic_ip6_socket.hpp:33
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
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
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
@ dgram
Socket type for datagram (udp for example)
socket_flags
Specifies socket send and receive behaviors.
Definition: mn_net_types.hpp:118
@ none
Use no flags for this call.
Definition: mn_allocator_typetraits.hpp:25