Ruby: ext/socket/rubysocket.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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