µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
posix/sys/socket.h
Go to the documentation of this file.
1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2015-2025 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software
6 * for any purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can
9 * be obtained from https://opensource.org/licenses/mit.
10 */
11
12#ifndef POSIX_IO_SYS_SOCKET_H_
13#define POSIX_IO_SYS_SOCKET_H_
14
15// ----------------------------------------------------------------------------
16
17#include <unistd.h>
18
19#if defined(_POSIX_VERSION)
20
21#pragma GCC diagnostic push
22#if defined(__clang__)
23#pragma clang diagnostic ignored "-Wgnu-include-next"
24#endif
25#include_next <sys/socket.h>
26#pragma GCC diagnostic pop
27
28#else
29
30#include <sys/types.h>
31
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
37 // --------------------------------------------------------------------------
38
39 typedef uint32_t socklen_t;
40
41#if !defined(OS_EXCLUDE_SOCKET_SA_FAMILY_T)
42 typedef unsigned int sa_family_t;
43#endif
44
45#if !defined(OS_EXCLUDE_SOCKET_STRUCT_SOCKADDR)
46 struct sockaddr
47 {
48 sa_family_t sa_family; // Address family.
49 char sa_data[]; // Socket address (variable-length data).
50 };
51#endif
52
53 int
54 accept (int socket, struct sockaddr* address, socklen_t* address_len);
55
56 int
57 bind (int socket, const struct sockaddr* address, socklen_t address_len);
58 int
59 connect (int socket, const struct sockaddr* address, socklen_t address_len);
60 int
61 getpeername (int socket, struct sockaddr* address, socklen_t* address_len);
62
63 int
64 getsockname (int socket, struct sockaddr* address, socklen_t* address_len);
65
66 int
67 getsockopt (int socket, int level, int option_name, void* option_value,
68 socklen_t* option_len);
69 int
70 listen (int socket, int backlog);
71
72 ssize_t
73 recv (int socket, void* buffer, size_t length, int flags);
74
75 ssize_t
76 recvfrom (int socket, void* buffer, size_t length, int flags,
77 struct sockaddr* address, socklen_t* address_len);
78
79 ssize_t
80 recvmsg (int socket, struct msghdr* message, int flags);
81
82 ssize_t
83 send (int socket, const void* buffer, size_t length, int flags);
84
85 ssize_t
86 sendmsg (int socket, const struct msghdr* message, int flags);
87
88 ssize_t
89 sendto (int socket, const void* message, size_t length, int flags,
90 const struct sockaddr* dest_addr, socklen_t dest_len);
91
92 int
93 setsockopt (int socket, int level, int option_name, const void* option_value,
94 socklen_t option_len);
95
96 int
97 shutdown (int socket, int how);
98
99 int
101
102 int
103 socket (int domain, int type, int protocol);
104
105 int
106 socketpair (int domain, int type, int protocol, int socket_vector[2]);
107
108 // --------------------------------------------------------------------------
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif /* defined(_POSIX_VERSION) */
115
116#endif /* POSIX_IO_SYS_SOCKET_H_ */
int shutdown(int socket, int how)
ssize_t recv(int socket, void *buffer, size_t length, int flags)
int accept(int socket, struct sockaddr *address, socklen_t *address_len)
int socketpair(int domain, int type, int protocol, int socket_vector[2])
ssize_t recvmsg(int socket, struct msghdr *message, int flags)
ssize_t sendmsg(int socket, const struct msghdr *message, int flags)
uint32_t socklen_t
int sockatmark(int socket)
int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
int bind(int socket, const struct sockaddr *address, socklen_t address_len)
unsigned int sa_family_t
int getpeername(int socket, struct sockaddr *address, socklen_t *address_len)
ssize_t send(int socket, const void *buffer, size_t length, int flags)
int getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
ssize_t sendto(int socket, const void *message, size_t length, int flags, const struct sockaddr *dest_addr, socklen_t dest_len)
int listen(int socket, int backlog)
ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, struct sockaddr *address, socklen_t *address_len)
int getsockname(int socket, struct sockaddr *address, socklen_t *address_len)
int connect(int socket, const struct sockaddr *address, socklen_t address_len)
int socket(int domain, int type, int protocol)
sa_family_t sa_family