13#ifndef CMSIS_PLUS_POSIX_IO_SOCKET_H_
14#define CMSIS_PLUS_POSIX_IO_SOCKET_H_
18#if defined(__cplusplus)
22#if defined(OS_USE_OS_APP_CONFIG_H)
23#include <cmsis-plus/os-app-config.h>
34#pragma GCC diagnostic push
36#pragma clang diagnostic ignored "-Wc++98-compat"
57#pragma GCC diagnostic push
59#elif defined(__GNUC__)
60#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
61#pragma GCC diagnostic ignored "-Wsuggest-final-types"
83 operator= (
const socket&) =
delete;
85 operator= (
socket&&) =
delete;
122 getsockopt (
int level,
int option_name,
void* option_value,
129 recv (
void* buffer,
size_t length,
int flags);
132 recvfrom (
void* buffer,
size_t length,
int flags,
136 recvmsg ( msghdr* message,
int flags);
139 send (
const void* buffer,
size_t length,
int flags);
142 sendmsg (
const msghdr* message,
int flags);
145 sendto (
const void* message,
size_t length,
int flags,
149 setsockopt (
int level,
int option_name,
const void* option_value,
161#pragma GCC diagnostic push
162#if defined(__clang__)
163#elif defined(__GNUC__)
164#pragma GCC diagnostic ignored "-Wredundant-tags"
170#pragma GCC diagnostic pop
208#pragma GCC diagnostic pop
290 do_recv (
void* buffer,
size_t length,
int flags) = 0;
300 do_send (
const void* buffer,
size_t length,
int flags) = 0;
306 do_sendto (
const void* message,
size_t length,
int flags,
402 template<
typename T,
typename L>
455 close (
void)
override;
474 getsockopt (
int level,
int option_name,
void* option_value,
478 listen (
int backlog)
override;
481 recv (
void* buffer,
size_t length,
int flags)
override;
484 recvfrom (
void* buffer,
size_t length,
int flags,
488 recvmsg ( msghdr* message,
int flags)
override;
491 send (
const void* buffer,
size_t length,
int flags)
override;
494 sendmsg (
const msghdr* message,
int flags)
override;
497 sendto (
const void* message,
size_t length,
int flags,
501 setsockopt (
int level,
int option_name,
const void* option_value,
565 { impl_instance_, ns }
567#if defined(OS_TRACE_POSIX_IO_SOCKET)
568 trace::printf (
"socket_implementable::%s()=@%p\n", __func__,
this);
575#if defined(OS_TRACE_POSIX_IO_SOCKET)
576 trace::printf (
"socket_implementable::%s() @%p\n", __func__,
this);
589 template<
typename T,
typename L>
593 { impl_instance_, ns },
596#if defined(OS_TRACE_POSIX_IO_SOCKET)
597 trace::printf (
"socket_lockable::%s()=@%p\n", __func__,
this);
601 template<
typename T,
typename L>
604#if defined(OS_TRACE_POSIX_IO_SOCKET)
605 trace::printf (
"socket_lockable::%s() @%p\n", __func__,
this);
611 template<
typename T,
typename L>
615 std::lock_guard<L> lock
621 template<
typename T,
typename L>
626 std::lock_guard<L> lock
632 template<
typename T,
typename L>
637 std::lock_guard<L> lock
643 template<
typename T,
typename L>
648 std::lock_guard<L> lock
654 template<
typename T,
typename L>
659 std::lock_guard<L> lock
665 template<
typename T,
typename L>
670 std::lock_guard<L> lock
676 template<
typename T,
typename L>
682 std::lock_guard<L> lock
688 template<
typename T,
typename L>
692 std::lock_guard<L> lock
698 template<
typename T,
typename L>
702 std::lock_guard<L> lock
708 template<
typename T,
typename L>
714 std::lock_guard<L> lock
720 template<
typename T,
typename L>
724 std::lock_guard<L> lock
730 template<
typename T,
typename L>
734 std::lock_guard<L> lock
740 template<
typename T,
typename L>
744 std::lock_guard<L> lock
750 template<
typename T,
typename L>
757 std::lock_guard<L> lock
760 return socket::sendto (message, length, flags, dest_addr, dest_len);
763 template<
typename T,
typename L>
766 const void* option_value,
769 std::lock_guard<L> lock
775 template<
typename T,
typename L>
779 std::lock_guard<L> lock
785 template<
typename T,
typename L>
789 std::lock_guard<L> lock
795 template<
typename T,
typename L>
806#pragma GCC diagnostic pop
virtual int do_bind(const sockaddr *address, socklen_t address_len)=0
virtual int do_getpeername(sockaddr *address, socklen_t *address_len)=0
virtual int do_getsockopt(int level, int option_name, void *option_value, socklen_t *option_len)=0
virtual socket * do_accept(sockaddr *address, socklen_t *address_len)=0
virtual int do_listen(int backlog)=0
virtual ~socket_impl() override
virtual int do_setsockopt(int level, int option_name, const void *option_value, socklen_t option_len)=0
virtual ssize_t do_recvfrom(void *buffer, size_t length, int flags, sockaddr *address, socklen_t *address_len)=0
virtual ssize_t do_sendmsg(const msghdr *message, int flags)=0
virtual ssize_t do_recv(void *buffer, size_t length, int flags)=0
virtual ssize_t do_send(const void *buffer, size_t length, int flags)=0
virtual ssize_t do_sendto(const void *message, size_t length, int flags, const sockaddr *dest_addr, socklen_t dest_len)=0
virtual int do_getsockname(sockaddr *address, socklen_t *address_len)=0
virtual ssize_t do_recvmsg(msghdr *message, int flags)=0
virtual int do_connect(const sockaddr *address, socklen_t address_len)=0
virtual int do_sockatmark(void)=0
virtual int do_shutdown(int how)=0
virtual ~socket_implementable()
value_type & impl(void) const
socket_implementable(class net_stack &ns)
virtual int sockatmark(void) override
virtual ssize_t send(const void *buffer, size_t length, int flags) override
virtual ssize_t recv(void *buffer, size_t length, int flags) override
virtual ssize_t sendmsg(const msghdr *message, int flags) override
virtual int setsockopt(int level, int option_name, const void *option_value, socklen_t option_len) override
virtual int listen(int backlog) override
virtual int close(void) override
virtual int shutdown(int how) override
virtual ssize_t sendto(const void *message, size_t length, int flags, const sockaddr *dest_addr, socklen_t dest_len) override
value_type & impl(void) const
virtual ~socket_lockable()
virtual int getsockname(sockaddr *address, socklen_t *address_len) override
virtual ssize_t recvmsg(msghdr *message, int flags) override
virtual class socket * accept(sockaddr *address, socklen_t *address_len) override
socket_lockable(class net_stack &ns, lockable_type &locker)
virtual int bind(const sockaddr *address, socklen_t address_len) override
virtual ssize_t recvfrom(void *buffer, size_t length, int flags, sockaddr *address, socklen_t *address_len) override
virtual int connect(const sockaddr *address, socklen_t address_len) override
virtual int getpeername(sockaddr *address, socklen_t *address_len) override
virtual int getsockopt(int level, int option_name, void *option_value, socklen_t *option_len) override
virtual int setsockopt(int level, int option_name, const void *option_value, socklen_t option_len)
virtual int sockatmark(void)
virtual int listen(int backlog)
virtual int getsockname(sockaddr *address, socklen_t *address_len)
virtual socket * accept(sockaddr *address, socklen_t *address_len)
virtual int bind(const sockaddr *address, socklen_t address_len)
virtual ssize_t recv(void *buffer, size_t length, int flags)
virtual ssize_t sendto(const void *message, size_t length, int flags, const sockaddr *dest_addr, socklen_t dest_len)
virtual ssize_t send(const void *buffer, size_t length, int flags)
virtual int getpeername(sockaddr *address, socklen_t *address_len)
virtual ssize_t sendmsg(const msghdr *message, int flags)
virtual int connect(const sockaddr *address, socklen_t address_len)
virtual ssize_t recvfrom(void *buffer, size_t length, int flags, sockaddr *address, socklen_t *address_len)
virtual int shutdown(int how)
virtual ~socket() override
virtual ssize_t recvmsg(msghdr *message, int flags)
virtual int getsockopt(int level, int option_name, void *option_value, socklen_t *option_len)
socket_impl & impl(void) const
class net_stack * net_stack(void)
The core of a double linked list, pointers to next, previous.
int printf(const char *format,...)
Write a formatted string to the trace device.
int socket(int domain, int type, int protocol)