Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

rubysocket.h
Go to the documentation of this file.
1 #ifndef RUBY_SOCKET_H
2 #define RUBY_SOCKET_H 1
3
4 #include "ruby/ruby.h"
5 #include "ruby/io.h"
6 #include "ruby/thread.h"
7 #include "ruby/util.h"
8 #include "internal.h"
9 #include <stdio.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12
13 #ifdef HAVE_UNISTD_H
14 # include <unistd.h>
15 #endif
16
17 #ifdef HAVE_SYS_UIO_H
18 # include <sys/uio.h>
19 #endif
20
21 #ifdef HAVE_XTI_H
22 # include <xti.h>
23 #endif
24
25 #ifdef _WIN32
26 # if defined(_MSC_VER)
27 # undef HAVE_TYPE_STRUCT_SOCKADDR_DL
28 # endif
29 /*
30 * FIXME: failures if we make nonblocking the default
31 * [ruby-core:89973] [ruby-core:89976] [ruby-core:89977] [Bug #14968]
32 */
33 # define RSOCK_NONBLOCK_DEFAULT (0)
34 #else
35 # define RSOCK_NONBLOCK_DEFAULT (0)
36 # include <sys/socket.h>
37 # include <netinet/in.h>
38 # ifdef HAVE_NETINET_IN_SYSTM_H
39 # include <netinet/in_systm.h>
40 # endif
41 # ifdef HAVE_NETINET_TCP_H
42 # include <netinet/tcp.h>
43 # endif
44 # ifdef HAVE_NETINET_TCP_FSM_H
45 # include <netinet/tcp_fsm.h>
46 # endif
47 # ifdef HAVE_NETINET_UDP_H
48 # include <netinet/udp.h>
49 # endif
50 # ifdef HAVE_ARPA_INET_H
51 # include <arpa/inet.h>
52 # endif
53 # include <netdb.h>
54 #endif
55
56 #ifdef HAVE_NETPACKET_PACKET_H
57 # include <netpacket/packet.h>
58 #endif
59 #ifdef HAVE_NET_ETHERNET_H
60 # include <net/ethernet.h>
61 #endif
62
63 #include <errno.h>
64
65 #ifdef HAVE_SYS_UN_H
66 # include <sys/un.h>
67 #endif
68
69 #if defined(HAVE_FCNTL)
70 # ifdef HAVE_SYS_SELECT_H
71 # include <sys/select.h>
72 # endif
73 # ifdef HAVE_SYS_TYPES_H
74 # include <sys/types.h>
75 # endif
76 # ifdef HAVE_SYS_TIME_H
77 # include <sys/time.h>
78 # endif
79 # ifdef HAVE_FCNTL_H
80 # include <fcntl.h>
81 # endif
82 #endif
83
84 #ifdef HAVE_IFADDRS_H
85 # ifdef __HAIKU__
86 # define _BSD_SOURCE
87 # endif
88 # include <ifaddrs.h>
89 #endif
90 #ifdef HAVE_SYS_IOCTL_H
91 # include <sys/ioctl.h>
92 #endif
93 #ifdef HAVE_SYS_SOCKIO_H
94 # include <sys/sockio.h>
95 #endif
96 #ifdef HAVE_NET_IF_H
97 # include <net/if.h>
98 #endif
99
100 #ifdef HAVE_SYS_PARAM_H
101 # include <sys/param.h>
102 #endif
103 #ifdef HAVE_SYS_UCRED_H
104 # include <sys/ucred.h>
105 #endif
106 #ifdef HAVE_UCRED_H
107 # include <ucred.h>
108 #endif
109 #ifdef HAVE_NET_IF_DL_H
110 # include <net/if_dl.h>
111 #endif
112
113 #ifndef HAVE_TYPE_SOCKLEN_T
114 typedef int socklen_t;
115 #endif
116
117 #ifdef NEED_IF_INDEXTONAME_DECL
118 char *if_indextoname(unsigned int, char *);
119 #endif
120 #ifdef NEED_IF_NAMETOINDEX_DECL
121 unsigned int if_nametoindex(const char *);
122 #endif
123
124 #define SOCKLEN_MAX \
125 (0 < (socklen_t)-1 ? \
126 ~(socklen_t)0 : \
127 (((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
128
129 #ifndef RSTRING_SOCKLEN
130 # define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
131 #endif
132
133 #ifndef EWOULDBLOCK
134 # define EWOULDBLOCK EAGAIN
135 #endif
136
137 /*
138 * workaround for NetBSD, OpenBSD and etc.
139 * The problem is since 4.4BSD-Lite.
140 * FreeBSD fix the problem at FreeBSD 2.2.0.
141 * NetBSD fix the problem at NetBSD 3.0 by kern/29624.
142 * OpenBSD fix the problem at OpenBSD 3.8.
143 */
144 #define pseudo_AF_FTIP pseudo_AF_RTIP
145
146 #ifndef HAVE_GETADDRINFO
147 # include "addrinfo.h"
148 #endif
149
150 #include "sockport.h"
151
152 #ifndef NI_MAXHOST
153 # define NI_MAXHOST 1025
154 #endif
155 #ifndef NI_MAXSERV
156 # define NI_MAXSERV 32
157 #endif
158
159 #ifdef AF_INET6
160 # define IS_IP_FAMILY(af) ((af) == AF_INET || (af) == AF_INET6)
161 #else
162 # define IS_IP_FAMILY(af) ((af) == AF_INET)
163 #endif
164
165 #ifndef IN6_IS_ADDR_UNIQUE_LOCAL
166 # define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
167 #endif
168
169 #ifndef HAVE_TYPE_STRUCT_SOCKADDR_STORAGE
170 /*
171 * RFC 2553: protocol-independent placeholder for socket addresses
172 */
173 # define _SS_MAXSIZE 128
174 # define _SS_ALIGNSIZE (sizeof(double))
175 # define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
176 # define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
177 _SS_PAD1SIZE - _SS_ALIGNSIZE)
178
179 struct sockaddr_storage {
180 # ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
181 unsigned char ss_len; /* address length */
182 unsigned char ss_family; /* address family */
183 # else
184 unsigned short ss_family;
185 # endif
186 char __ss_pad1[_SS_PAD1SIZE];
187 double __ss_align; /* force desired structure storage alignment */
188 char __ss_pad2[_SS_PAD2SIZE];
189 };
190 #endif
191
192 typedef union {
193 struct sockaddr addr;
194 struct sockaddr_in in;
195 #ifdef AF_INET6
196 struct sockaddr_in6 in6;
197 #endif
198 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
199 struct sockaddr_un un;
200 #endif
201 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_DL
202 struct sockaddr_dl dl; /* AF_LINK */
203 #endif
204 struct sockaddr_storage storage;
205 char place_holder[2048]; /* sockaddr_storage is not enough for Unix domain sockets on SunOS and Darwin. */
206 } union_sockaddr;
207
208 #ifdef __APPLE__
209 /*
210 * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
211 * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
212 * 32bit-aligned.
213 */
214 # undef __DARWIN_ALIGNBYTES
215 # define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
216 #endif
217
218 #if defined(_AIX)
219 # ifndef CMSG_SPACE
220 # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
221 # endif
222 # ifndef CMSG_LEN
223 # define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
224 # endif
225 #endif
226
227 #define INET_CLIENT 0
228 #define INET_SERVER 1
229 #define INET_SOCKS 2
230
231 extern int rsock_do_not_reverse_lookup;
232 extern int rsock_cmsg_cloexec_state;
233 #define FMODE_NOREVLOOKUP 0x100
234
235 /* common socket families only */
236 #define FMODE_UNIX 0x00200000
237 #define FMODE_INET 0x00400000
238 #define FMODE_INET6 0x00800000
239 #define FMODE_SOCK (FMODE_UNIX|FMODE_INET|FMODE_INET6)
240
241 extern VALUE rb_cBasicSocket;
242 extern VALUE rb_cIPSocket;
243 extern VALUE rb_cTCPSocket;
244 extern VALUE rb_cTCPServer;
245 extern VALUE rb_cUDPSocket;
246 #ifdef HAVE_SYS_UN_H
247 extern VALUE rb_cUNIXSocket;
248 extern VALUE rb_cUNIXServer;
249 #endif
250 extern VALUE rb_cSocket;
251 extern VALUE rb_cAddrinfo;
252 extern VALUE rb_cSockOpt;
253
254 extern VALUE rb_eSocket;
255
256 #ifdef SOCKS
257 extern VALUE rb_cSOCKSSocket;
258 # ifdef SOCKS5
259 # include <socks.h>
260 # else
261 void SOCKSinit();
262 int Rconnect();
263 # endif
264 #endif
265
266 #include "constdefs.h"
267
268 #define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
269
270 #define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
271 #define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
272 #define SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
273 VALUE rsock_sockaddr_string_value(volatile VALUE *);
274 char *rsock_sockaddr_string_value_ptr(volatile VALUE *);
275 VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret);
276
277 VALUE rb_check_sockaddr_string_type(VALUE);
278
279 NORETURN(void rsock_raise_socket_error(const char *, int));
280
281 int rsock_family_arg(VALUE domain);
282 int rsock_socktype_arg(VALUE type);
283 int rsock_level_arg(int family, VALUE level);
284 int rsock_optname_arg(int family, int level, VALUE optname);
285 int rsock_cmsg_type_arg(int family, int level, VALUE type);
286 int rsock_shutdown_how_arg(VALUE how);
287
288 int rsock_getfamily(rb_io_t *fptr);
289
290 struct rb_addrinfo {
291 struct addrinfo *ai;
292 int allocated_by_malloc;
293 };
294 int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res);
295 void rb_freeaddrinfo(struct rb_addrinfo *ai);
296 VALUE rsock_freeaddrinfo(VALUE arg);
297 int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
298 int rsock_fd_family(int fd);
299 struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags);
300 struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
301 VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
302 VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
303
304 VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
305 VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai);
306
307 VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen);
308 VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup);
309 VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t));
310 VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret);
311 socklen_t rsock_sockaddr_len(struct sockaddr *addr);
312 VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len);
313
314 int rsock_revlookup_flag(VALUE revlookup, int *norevlookup);
315
316 #ifdef HAVE_SYS_UN_H
317 VALUE rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len);
318 VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
319 socklen_t rsock_unix_sockaddr_len(VALUE path);
320 #endif
321
322 int rsock_socket(int domain, int type, int proto);
323 int rsock_detect_cloexec(int fd);
324 VALUE rsock_init_sock(VALUE sock, int fd);
325 VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass);
326 VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type);
327 VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server);
328
329 struct rsock_send_arg {
330 int fd, flags;
331 VALUE mesg;
332 struct sockaddr *to;
333 socklen_t tolen;
334 };
335
336 VALUE rsock_sendto_blocking(void *data);
337 VALUE rsock_send_blocking(void *data);
338 VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock);
339
340 enum sock_recv_type {
341 RECV_RECV, /* BasicSocket#recv(no from) */
342 RECV_IP, /* IPSocket#recvfrom */
343 RECV_UNIX, /* UNIXSocket#recvfrom */
344 RECV_SOCKET /* Socket#recvfrom */
345 };
346
347 VALUE rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
348 VALUE ex, enum sock_recv_type from);
349 VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
350
351 int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
352
353 VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
354 VALUE rsock_s_accept_nonblock(VALUE klass, VALUE ex, rb_io_t *fptr,
355 struct sockaddr *sockaddr, socklen_t *len);
356 VALUE rsock_sock_listen(VALUE sock, VALUE log);
357
358 VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
359
360 #if defined(HAVE_SENDMSG)
361 VALUE rsock_bsock_sendmsg(VALUE sock, VALUE data, VALUE flags,
362 VALUE dest_sockaddr, VALUE controls);
363 VALUE rsock_bsock_sendmsg_nonblock(VALUE sock, VALUE data, VALUE flags,
364 VALUE dest_sockaddr, VALUE controls, VALUE ex);
365 #else
366 #define rsock_bsock_sendmsg rb_f_notimplement
367 #define rsock_bsock_sendmsg_nonblock rb_f_notimplement
368 #endif
369
370 #if defined(HAVE_RECVMSG)
371 VALUE rsock_bsock_recvmsg(VALUE sock, VALUE dlen, VALUE clen, VALUE flags,
372 VALUE scm_rights);
373 VALUE rsock_bsock_recvmsg_nonblock(VALUE sock, VALUE dlen, VALUE clen,
374 VALUE flags, VALUE scm_rights, VALUE ex);
375 ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
376 #else
377 #define rsock_bsock_recvmsg rb_f_notimplement
378 #define rsock_bsock_recvmsg_nonblock rb_f_notimplement
379 #endif
380
381 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
382 void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
383 #endif
384
385 void rsock_init_basicsocket(void);
386 void rsock_init_ipsocket(void);
387 void rsock_init_tcpsocket(void);
388 void rsock_init_tcpserver(void);
389 void rsock_init_sockssocket(void);
390 void rsock_init_udpsocket(void);
391 void rsock_init_unixsocket(void);
392 void rsock_init_unixserver(void);
393 void rsock_init_socket_constants(void);
394 void rsock_init_ancdata(void);
395 void rsock_init_addrinfo(void);
396 void rsock_init_sockopt(void);
397 void rsock_init_sockifaddr(void);
398 void rsock_init_socket_init(void);
399
400 NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE));
401 NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE));
402 NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len));
403 NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai));
404 NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai));
405
406 NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
407 NORETURN(void rsock_sys_fail_path(const char *, VALUE));
408 NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
409 NORETURN(void rsock_sys_fail_raddrinfo(const char *, VALUE rai));
410 NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VALUE rai));
411
412 /*
413 * It is safe on Linux to attempt using a socket without waiting on it in
414 * all cases. For some syscalls (e.g. accept/accept4), blocking on the
415 * syscall instead of relying on select/poll allows the kernel to use
416 * "wake-one" behavior and avoid the thundering herd problem.
417 * This is likely safe on all other *nix-like systems, so this safe list
418 * can be expanded by interested parties.
419 */
420 #if defined(__linux__)
421 static inline int rsock_maybe_fd_writable(int fd) { return 1; }
422 static inline void rsock_maybe_wait_fd(int fd) { }
423 # ifdef MSG_DONTWAIT
424 # define MSG_DONTWAIT_RELIABLE 1
425 # endif
426 #else /* some systems (mswin/mingw) need these. ref: r36946 */
427 # define rsock_maybe_fd_writable(fd) rb_thread_fd_writable((fd))
428 # define rsock_maybe_wait_fd(fd) rb_thread_wait_fd((fd))
429 #endif
430
431 /*
432 * some OSes may support MSG_DONTWAIT inconsistently depending on socket
433 * type, we only expect Linux to support it consistently for all socket types.
434 */
435 #ifndef MSG_DONTWAIT_RELIABLE
436 # define MSG_DONTWAIT_RELIABLE 0
437 #endif
438
439 VALUE rsock_read_nonblock(VALUE sock, VALUE length, VALUE buf, VALUE ex);
440 VALUE rsock_write_nonblock(VALUE sock, VALUE buf, VALUE ex);
441
442 void rsock_make_fd_nonblock(int fd);
443
444 #if !defined HAVE_INET_NTOP && ! defined _WIN32
445 const char *inet_ntop(int, const void *, char *, size_t);
446 #elif defined __MINGW32__
447 # define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
448 #elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
449 const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
450 #endif
451
452 #endif
rsock_send_arg::tolen
socklen_t tolen
Definition: rubysocket.h:333
rsock_sockaddr_string_value
VALUE rsock_sockaddr_string_value(volatile VALUE *)
Definition: raddrinfo.c:2597
_SS_PAD1SIZE
#define _SS_PAD1SIZE
Definition: rubysocket.h:175
rsock_maybe_fd_writable
#define rsock_maybe_fd_writable(fd)
Definition: rubysocket.h:427
rb_cSocket
VALUE rb_cSocket
Definition: init.c:26
rb_eSocket
VALUE rb_eSocket
Definition: init.c:29
rsock_init_unixsock
VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server)
rb_cAddrinfo
VALUE rb_cAddrinfo
Definition: init.c:27
rsock_read_nonblock
VALUE rsock_read_nonblock(VALUE sock, VALUE length, VALUE buf, VALUE ex)
rsock_init_unixserver
void rsock_init_unixserver(void)
Definition: unixserver.c:109
proto
#define proto(p)
Definition: sdbm.h:60
rsock_getaddrinfo
struct rb_addrinfo * rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
Definition: raddrinfo.c:576
path
VALUE path
Definition: rb_mjit_min_header-2.7.0.h:7351
rsock_send_arg::mesg
VALUE mesg
Definition: rubysocket.h:331
rsock_detect_cloexec
int rsock_detect_cloexec(int fd)
Definition: init.c:413
rsock_init_unixsocket
void rsock_init_unixsocket(void)
Definition: unixsocket.c:576
rsock_send_arg::fd
int fd
Definition: rubysocket.h:330
sockaddr_storage::__ss_align
double __ss_align
Definition: rubysocket.h:187
RECV_RECV
@ RECV_RECV
Definition: rubysocket.h:341
rb_cIPSocket
VALUE rb_cIPSocket
Definition: init.c:18
rsock_sys_fail_raddrinfo
void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
Definition: socket.c:71
VALUE
unsigned long VALUE
Definition: ruby.h:102
rsock_send_arg::to
struct sockaddr * to
Definition: rubysocket.h:332
rsock_syserr_fail_raddrinfo_or_sockaddr
void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai)
Definition: socket.c:94
rsock_init_sockopt
void rsock_init_sockopt(void)
Definition: option.c:1438
union_sockaddr
Definition: rubysocket.h:192
rsock_bsock_sendmsg
#define rsock_bsock_sendmsg
Definition: rubysocket.h:366
sockaddr_storage::__ss_pad2
char __ss_pad2[_SS_PAD2SIZE]
Definition: rubysocket.h:188
sockaddr_storage
Definition: rubysocket.h:179
rsock_make_ipaddr
VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen)
Definition: raddrinfo.c:470
rsock_init_sock
VALUE rsock_init_sock(VALUE sock, int fd)
Definition: init.c:78
rsock_revlookup_flag
int rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
Definition: ipsocket.c:179
rsock_init_ipsocket
void rsock_init_ipsocket(void)
Definition: ipsocket.c:371
rb_addrinfo::ai
struct addrinfo * ai
Definition: rubysocket.h:291
addrinfo.h
rb_cUDPSocket
VALUE rb_cUDPSocket
Definition: init.c:21
rsock_freeaddrinfo
VALUE rsock_freeaddrinfo(VALUE arg)
Definition: raddrinfo.c:808
rsock_make_hostent
VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, socklen_t))
Definition: raddrinfo.c:816
ssize_t
_ssize_t ssize_t
Definition: rb_mjit_min_header-2.7.0.h:1329
rsock_connect
int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
Definition: init.c:608
rb_addrinfo
Definition: rubysocket.h:290
socklen_t
int socklen_t
Definition: getaddrinfo.c:83
ruby.h
rsock_bsock_recvmsg
#define rsock_bsock_recvmsg
Definition: rubysocket.h:377
rsock_level_arg
int rsock_level_arg(int family, VALUE level)
Definition: constants.c:56
rb_cBasicSocket
VALUE rb_cBasicSocket
Definition: init.c:17
rsock_getfamily
int rsock_getfamily(rb_io_t *fptr)
Definition: init.c:787
rsock_do_not_reverse_lookup
int rsock_do_not_reverse_lookup
Definition: init.c:35
v
int VALUE v
Definition: rb_mjit_min_header-2.7.0.h:12332
rsock_init_basicsocket
void rsock_init_basicsocket(void)
Definition: basicsocket.c:704
rsock_io_socket_addrinfo
VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2655
rsock_addrinfo
struct rb_addrinfo * rsock_addrinfo(VALUE host, VALUE port, int family, int socktype, int flags)
Definition: raddrinfo.c:653
rsock_syserr_fail_host_port
void rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
Definition: socket.c:24
rsock_s_recvfrom_nonblock
VALUE rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex, enum sock_recv_type from)
Definition: init.c:230
rsock_fd_socket_addrinfo
VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2636
RECV_IP
@ RECV_IP
Definition: rubysocket.h:342
rsock_init_udpsocket
void rsock_init_udpsocket(void)
Definition: udpsocket.c:230
rb_cSockOpt
VALUE rb_cSockOpt
Definition: option.c:3
rsock_sockaddr_string_value_ptr
char * rsock_sockaddr_string_value_ptr(volatile VALUE *)
Definition: raddrinfo.c:2621
rsock_s_accept_nonblock
VALUE rsock_s_accept_nonblock(VALUE klass, VALUE ex, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:710
rsock_cmsg_cloexec_state
int rsock_cmsg_cloexec_state
Definition: ancdata.c:5
rb_cTCPServer
VALUE rb_cTCPServer
Definition: init.c:20
rsock_s_recvfrom
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
Definition: init.c:168
rsock_sockaddr_len
socklen_t rsock_sockaddr_len(struct sockaddr *addr)
rsock_init_tcpserver
void rsock_init_tcpserver(void)
Definition: tcpserver.c:106
rsock_addrinfo_inspect_sockaddr
VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai)
Definition: raddrinfo.c:1641
inet_ntop
const char * inet_ntop(int, const void *, char *, size_t)
Definition: option.c:651
msghdr
Definition: win32.h:229
rsock_send_arg
Definition: rubysocket.h:329
rsock_write_nonblock
VALUE rsock_write_nonblock(VALUE sock, VALUE buf, VALUE ex)
rsock_cmsg_type_arg
int rsock_cmsg_type_arg(int family, int level, VALUE type)
Definition: constants.c:99
rsock_sys_fail_host_port
void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
Definition: socket.c:18
rsock_init_inetsock
VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type)
Definition: ipsocket.c:159
rsock_shutdown_how_arg
int rsock_shutdown_how_arg(VALUE how)
Definition: constants.c:130
rsock_sockopt_new
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data)
Definition: option.c:107
rsock_maybe_wait_fd
#define rsock_maybe_wait_fd(fd)
Definition: rubysocket.h:428
rsock_init_sockifaddr
void rsock_init_sockifaddr(void)
Definition: ifaddr.c:454
rsock_sys_fail_sockaddr
void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:55
constdefs.h
rsock_init_socket_constants
void rsock_init_socket_constants(void)
Definition: constants.c:140
rsock_ipaddr
VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
Definition: raddrinfo.c:665
rsock_send_arg::flags
int flags
Definition: rubysocket.h:330
buf
unsigned char buf[MIME_BUF_SIZE]
Definition: nkf.c:4322
rsock_socktype_arg
int rsock_socktype_arg(VALUE type)
Definition: constants.c:49
log
double log(double)
rsock_init_tcpsocket
void rsock_init_tcpsocket(void)
Definition: tcpsocket.c:68
internal.h
arg
VALUE arg
Definition: rb_mjit_min_header-2.7.0.h:5601
argv
char ** argv
Definition: ruby.c:223
rsock_syserr_fail_path
void rsock_syserr_fail_path(int err, const char *mesg, VALUE path)
Definition: socket.c:41
rsock_inspect_sockaddr
VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret)
Definition: raddrinfo.c:1266
NORETURN
NORETURN(void rsock_raise_socket_error(const char *, int))
sock_recv_type
sock_recv_type
Definition: rubysocket.h:340
klass
VALUE klass
Definition: rb_mjit_min_header-2.7.0.h:13254
rsock_family_arg
int rsock_family_arg(VALUE domain)
Definition: constants.c:42
rsock_syserr_fail_sockaddr
void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:61
str
char str[HTML_ESCAPE_MAX_LEN+1]
Definition: escape.c:18
rsock_sockaddr_string_value_with_addrinfo
VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret)
Definition: raddrinfo.c:2608
rsock_optname_arg
int rsock_optname_arg(int family, int level, VALUE optname)
Definition: constants.c:68
rb_getaddrinfo
int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res)
Definition: raddrinfo.c:309
rsock_s_accept
VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:752
io.h
argc
int argc
Definition: ruby.c:222
rb_getnameinfo
int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
Definition: raddrinfo.c:437
err
int err
Definition: win32.c:135
rsock_bsock_recvmsg_nonblock
#define rsock_bsock_recvmsg_nonblock
Definition: rubysocket.h:378
rsock_init_addrinfo
void rsock_init_addrinfo(void)
Definition: raddrinfo.c:2681
_SS_PAD2SIZE
#define _SS_PAD2SIZE
Definition: rubysocket.h:176
rsock_sock_listen
VALUE rsock_sock_listen(VALUE sock, VALUE log)
Definition: socket.c:653
rsock_addrinfo_new
VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname)
Definition: raddrinfo.c:910
rsock_raise_socket_error
void rsock_raise_socket_error(const char *reason, int error)
Definition: init.c:39
len
uint8_t len
Definition: escape.c:17
rb_freeaddrinfo
void rb_freeaddrinfo(struct rb_addrinfo *ai)
Definition: raddrinfo.c:396
sockaddr_storage::__ss_pad1
char __ss_pad1[_SS_PAD1SIZE]
Definition: rubysocket.h:186
rsock_fd_family
int rsock_fd_family(int fd)
Definition: raddrinfo.c:640
rsock_bsock_send
VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
Definition: basicsocket.c:540
rsock_syserr_fail_raddrinfo
void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)
Definition: socket.c:77
rsock_init_socket_init
void rsock_init_socket_init(void)
Definition: init.c:819
rsock_sys_fail_path
void rsock_sys_fail_path(const char *mesg, VALUE path)
Definition: socket.c:35
thread.h
rsock_socket
int rsock_socket(int domain, int type, int proto)
Definition: init.c:492
util.h
sockaddr_storage::ss_family
unsigned short ss_family
Definition: rubysocket.h:184
rb_io_t
Definition: io.h:66
rsock_init_ancdata
void rsock_init_ancdata(void)
Definition: ancdata.c:1697
rb_check_sockaddr_string_type
VALUE rb_check_sockaddr_string_type(VALUE)
Definition: raddrinfo.c:2628
rb_addrinfo::allocated_by_malloc
int allocated_by_malloc
Definition: rubysocket.h:292
socklen_t
int socklen_t
Definition: rubysocket.h:114
sockport.h
addrinfo
Definition: addrinfo.h:131
RECV_SOCKET
@ RECV_SOCKET
Definition: rubysocket.h:344
rsock_sendto_blocking
VALUE rsock_sendto_blocking(void *data)
Definition: init.c:100
rsock_send_blocking
VALUE rsock_send_blocking(void *data)
Definition: init.c:111
RECV_UNIX
@ RECV_UNIX
Definition: rubysocket.h:343
rsock_make_fd_nonblock
void rsock_make_fd_nonblock(int fd)
Definition: init.c:639
rsock_init_sockssocket
void rsock_init_sockssocket(void)
Definition: sockssocket.c:58
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition: cxxanyargs.hpp:39
rsock_sock_s_socketpair
VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
rb_cTCPSocket
VALUE rb_cTCPSocket
Definition: init.c:19
rsock_sockaddr_obj
VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len)
rsock_bsock_sendmsg_nonblock
#define rsock_bsock_sendmsg_nonblock
Definition: rubysocket.h:367
rsock_sys_fail_raddrinfo_or_sockaddr
void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
Definition: socket.c:88