28#ifndef CMSIS_PLUS_POSIX_IO_SOCKET_H_
29#define CMSIS_PLUS_POSIX_IO_SOCKET_H_
33#if defined(__cplusplus)
37#if defined(OS_USE_OS_APP_CONFIG_H)
38#include <cmsis-plus/os-app-config.h>
49#pragma GCC diagnostic push
52#pragma clang diagnostic ignored "-Wc++98-compat"
93 operator= (
const socket&) =
delete;
95 operator= (
socket&&) =
delete;
132 getsockopt (
int level,
int option_name,
void* option_value,
139 recv (
void* buffer,
size_t length,
int flags);
142 recvfrom (
void* buffer,
size_t length,
int flags,
146 recvmsg (
struct msghdr* message,
int flags);
149 send (
const void* buffer,
size_t length,
int flags);
152 sendmsg (
const struct msghdr* message,
int flags);
155 sendto (
const void* message,
size_t length,
int flags,
159 setsockopt (
int level,
int option_name,
const void* option_value,
291 do_recv (
void* buffer,
size_t length,
int flags) = 0;
301 do_send (
const void* buffer,
size_t length,
int flags) = 0;
307 do_sendto (
const void* message,
size_t length,
int flags,
403 template<
typename T,
typename L>
456 close (
void)
override;
475 getsockopt (
int level,
int option_name,
void* option_value,
479 listen (
int backlog)
override;
482 recv (
void* buffer,
size_t length,
int flags)
override;
485 recvfrom (
void* buffer,
size_t length,
int flags,
489 recvmsg (
struct msghdr* message,
int flags)
override;
492 send (
const void* buffer,
size_t length,
int flags)
override;
495 sendmsg (
const struct msghdr* message,
int flags)
override;
498 sendto (
const void* message,
size_t length,
int flags,
502 setsockopt (
int level,
int option_name,
const void* option_value,
566 { impl_instance_, ns }
568#if defined(OS_TRACE_POSIX_IO_SOCKET)
569 trace::printf (
"socket_implementable::%s()=@%p\n", __func__,
this);
576#if defined(OS_TRACE_POSIX_IO_SOCKET)
577 trace::printf (
"socket_implementable::%s() @%p\n", __func__,
this);
590 template<
typename T,
typename L>
594 { impl_instance_, ns },
597#if defined(OS_TRACE_POSIX_IO_SOCKET)
598 trace::printf (
"socket_lockable::%s()=@%p\n", __func__,
this);
602 template<
typename T,
typename L>
605#if defined(OS_TRACE_POSIX_IO_SOCKET)
606 trace::printf (
"socket_lockable::%s() @%p\n", __func__,
this);
612 template<
typename T,
typename L>
616 std::lock_guard<L> lock
622 template<
typename T,
typename L>
627 std::lock_guard<L> lock
633 template<
typename T,
typename L>
638 std::lock_guard<L> lock
644 template<
typename T,
typename L>
649 std::lock_guard<L> lock
655 template<
typename T,
typename L>
660 std::lock_guard<L> lock
666 template<
typename T,
typename L>
671 std::lock_guard<L> lock
677 template<
typename T,
typename L>
683 std::lock_guard<L> lock
689 template<
typename T,
typename L>
693 std::lock_guard<L> lock
699 template<
typename T,
typename L>
703 std::lock_guard<L> lock
709 template<
typename T,
typename L>
715 std::lock_guard<L> lock
721 template<
typename T,
typename L>
725 std::lock_guard<L> lock
731 template<
typename T,
typename L>
735 std::lock_guard<L> lock
741 template<
typename T,
typename L>
745 std::lock_guard<L> lock
751 template<
typename T,
typename L>
758 std::lock_guard<L> lock
761 return socket::sendto (message, length, flags, dest_addr, dest_len);
764 template<
typename T,
typename L>
767 const void* option_value,
770 std::lock_guard<L> lock
776 template<
typename T,
typename L>
780 std::lock_guard<L> lock
786 template<
typename T,
typename L>
790 std::lock_guard<L> lock
796 template<
typename T,
typename L>
807#pragma GCC diagnostic pop
virtual int do_getsockopt(int level, int option_name, void *option_value, socklen_t *option_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_recv(void *buffer, size_t length, int flags)=0
virtual int do_getpeername(struct sockaddr *address, socklen_t *address_len)=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 struct sockaddr *dest_addr, socklen_t dest_len)=0
virtual ssize_t do_recvmsg(struct msghdr *message, int flags)=0
virtual int do_bind(const struct sockaddr *address, socklen_t address_len)=0
virtual class socket * do_accept(struct sockaddr *address, socklen_t *address_len)=0
virtual ssize_t do_sendmsg(const struct msghdr *message, int flags)=0
virtual ssize_t do_recvfrom(void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)=0
virtual int do_sockatmark(void)=0
virtual int do_connect(const struct sockaddr *address, socklen_t address_len)=0
virtual int do_shutdown(int how)=0
virtual int do_getsockname(struct sockaddr *address, socklen_t *address_len)=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 recvfrom(void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len) override
virtual ssize_t recv(void *buffer, size_t length, int flags) override
virtual int connect(const struct sockaddr *address, socklen_t address_len) 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 recvmsg(struct msghdr *message, int flags) override
virtual int bind(const struct sockaddr *address, socklen_t address_len) override
virtual ssize_t sendmsg(const struct msghdr *message, int flags) override
value_type & impl(void) const
virtual ~socket_lockable()
virtual ssize_t sendto(const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len) override
socket_lockable(class net_stack &ns, lockable_type &locker)
virtual class socket * accept(struct sockaddr *address, socklen_t *address_len) override
virtual int getpeername(struct sockaddr *address, socklen_t *address_len) override
virtual int getsockname(struct 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 getsockname(struct sockaddr *address, socklen_t *address_len)
virtual int listen(int backlog)
virtual ssize_t recvmsg(struct msghdr *message, int flags)
virtual ssize_t sendmsg(const struct msghdr *message, int flags)
virtual int getpeername(struct sockaddr *address, socklen_t *address_len)
virtual ssize_t recv(void *buffer, size_t length, int flags)
virtual ssize_t send(const void *buffer, size_t length, int flags)
virtual ssize_t recvfrom(void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
virtual int shutdown(int how)
virtual int connect(const struct sockaddr *address, socklen_t address_len)
virtual ~socket() override
virtual int bind(const struct sockaddr *address, socklen_t address_len)
virtual int getsockopt(int level, int option_name, void *option_value, socklen_t *option_len)
virtual class socket * accept(struct sockaddr *address, socklen_t *address_len)
socket_impl & impl(void) const
class net_stack * net_stack(void)
virtual ssize_t sendto(const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
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)