µ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++ distribution.
3 * (https://github.com/micro-os-plus)
4 * Copyright (c) 2015 Liviu Ionescu.
5 *
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following
13 * conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#ifndef POSIX_IO_SYS_SOCKET_H_
29#define POSIX_IO_SYS_SOCKET_H_
30
31// ----------------------------------------------------------------------------
32
33#include <unistd.h>
34
35#if defined(_POSIX_VERSION)
36
37#pragma GCC diagnostic push
38#if defined(__clang__)
39#pragma clang diagnostic ignored "-Wgnu-include-next"
40#endif
41#include_next <sys/socket.h>
42#pragma GCC diagnostic pop
43
44#else
45
46#include <sys/types.h>
47
48#ifdef __cplusplus
49extern "C"
50{
51#endif
52
53// ----------------------------------------------------------------------------
54
55 typedef uint32_t socklen_t;
56
57#if !defined (OS_EXCLUDE_SOCKET_SA_FAMILY_T)
58 typedef unsigned int sa_family_t;
59#endif
60
61#if !defined (OS_EXCLUDE_SOCKET_STRUCT_SOCKADDR)
62 struct sockaddr
63 {
64 sa_family_t sa_family; //Address family.
65 char sa_data[]; // Socket address (variable-length data).
66 };
67#endif
68
69 int
70 accept (int socket, struct sockaddr* address, socklen_t* address_len);
71
72 int
73 bind (int socket, const struct sockaddr* address, socklen_t address_len);
74 int
75 connect (int socket, const struct sockaddr* address, socklen_t address_len);
76 int
77 getpeername (int socket, struct sockaddr* address, socklen_t* address_len);
78
79 int
80 getsockname (int socket, struct sockaddr* address, socklen_t* address_len);
81
82 int
83 getsockopt (int socket, int level, int option_name, void* option_value,
84 socklen_t* option_len);
85 int
86 listen (int socket, int backlog);
87
88 ssize_t
89 recv (int socket, void* buffer, size_t length, int flags);
90
91 ssize_t
92 recvfrom (int socket, void* buffer, size_t length, int flags,
93 struct sockaddr* address, socklen_t* address_len);
94
95 ssize_t
96 recvmsg (int socket, struct msghdr* message, int flags);
97
98 ssize_t
99 send (int socket, const void* buffer, size_t length, int flags);
100
101 ssize_t
102 sendmsg (int socket, const struct msghdr* message, int flags);
103
104 ssize_t
105 sendto (int socket, const void* message, size_t length, int flags,
106 const struct sockaddr* dest_addr, socklen_t dest_len);
107
108 int
109 setsockopt (int socket, int level, int option_name, const void* option_value,
110 socklen_t option_len);
111
112 int
113 shutdown (int socket, int how);
114
115 int
117
118 int
119 socket (int domain, int type, int protocol);
120
121 int
122 socketpair (int domain, int type, int protocol, int socket_vector[2]);
123
124// ----------------------------------------------------------------------------
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif /* defined(_POSIX_VERSION) */
131
132#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