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