1 /* Copyright (C) 2010-2022 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (net_socket.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef _LIBRETRO_SDK_NET_SOCKET_H
24 #define _LIBRETRO_SDK_NET_SOCKET_H
30 #include <net/net_compat.h>
32 #include <retro_common_api.h>
38 SOCKET_DOMAIN_INET = 0
43 SOCKET_TYPE_DATAGRAM = 0,
50 SOCKET_PROTOCOL_NONE = 0,
55 typedef struct socket_target
59 enum socket_domain domain;
60 enum socket_protocol prot;
63 int socket_init(void **address, uint16_t port, const char *server,
64 enum socket_type type, int family);
66 int socket_next(void **address);
68 int socket_close(int fd);
70 bool socket_set_block(int fd, bool block);
72 /* TODO: all callers should be converted to socket_set_block() */
73 bool socket_nonblock(int fd);
75 int socket_select(int nfds, fd_set *readfds, fd_set *writefds,
76 fd_set *errorfds, struct timeval *timeout);
78 #ifdef NETWORK_HAVE_POLL
79 int socket_poll(struct pollfd *fds, unsigned nfds, int timeout);
82 bool socket_wait(int fd, bool *rd, bool *wr, int timeout);
84 bool socket_send_all_blocking(int fd, const void *data_, size_t size, bool no_signal);
86 bool socket_send_all_blocking_with_timeout(int fd,
87 const void *data_, size_t size,
88 int timeout, bool no_signal);
90 ssize_t socket_send_all_nonblocking(int fd, const void *data_, size_t size,
93 bool socket_receive_all_blocking(int fd, void *data_, size_t size);
95 bool socket_receive_all_blocking_with_timeout(int fd,
96 void *data_, size_t size,
99 ssize_t socket_receive_all_nonblocking(int fd, bool *error,
100 void *data_, size_t size);
102 bool socket_bind(int fd, void *data);
104 int socket_connect(int fd, void *data);
106 bool socket_connect_with_timeout(int fd, void *data, int timeout);
110 enum socket_domain domain_type,
111 enum socket_type socket_type,
112 enum socket_protocol protocol_type);
114 void socket_set_target(void *data, socket_target_t *in_addr);