Ruby: ext/socket/rubysocket.h File Reference

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

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
rubysocket.h File Reference
`#include "ruby/config.h"`
`#include <RUBY_EXTCONF_H>`
`#include <errno.h>`
`#include <stdio.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <netdb.h>`
`#include "addrinfo.h"`
`#include "internal.h"`
`#include "internal/array.h"`
`#include "internal/error.h"`
`#include "internal/gc.h"`
`#include "internal/io.h"`
`#include "internal/thread.h"`
`#include "internal/vm.h"`
`#include "ruby/io.h"`
`#include "ruby/ruby.h"`
`#include "ruby/thread.h"`
`#include "ruby/util.h"`
`#include "sockport.h"`
`#include "constdefs.h"`

Go to the source code of this file.

## Data Structures
struct | sockaddr_storage
union | union_sockaddr
struct | rb_addrinfo
struct | rsock_send_arg

## Macros
#define | SOCKLEN_MAX
#define | RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
#define | EWOULDBLOCK EAGAIN
#define | pseudo_AF_FTIP pseudo_AF_RTIP
#define | IS_IP_FAMILY(af) ((af) == AF_INET)
#define | IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
#define | _SS_MAXSIZE 128
#define | _SS_ALIGNSIZE (sizeof(double))
#define | _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
#define | _SS_PAD2SIZE
#define | INET_CLIENT 0
#define | INET_SERVER 1
#define | INET_SOCKS 2
#define | FMODE_NOREVLOOKUP 0x100
#define | FMODE_UNIX 0x00200000
#define | FMODE_INET 0x00400000
#define | FMODE_INET6 0x00800000
#define | FMODE_SOCK (FMODE_UNIX|FMODE_INET|FMODE_INET6)
#define | BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
#define | SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
#define | SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
#define | SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
#define | rsock_bsock_sendmsg rb_f_notimplement
#define | rsock_bsock_sendmsg_nonblock rb_f_notimplement
#define | rsock_bsock_recvmsg rb_f_notimplement
#define | rsock_bsock_recvmsg_nonblock rb_f_notimplement
#define | rsock_maybe_fd_writable(fd) rb_thread_fd_writable((fd))
#define | rsock_maybe_wait_fd(fd) rb_thread_wait_fd((fd))
#define | MSG_DONTWAIT_RELIABLE 0

## Typedefs
typedef int | socklen_t

## Enumerations
enum | sock_recv_type { RECV_RECV , RECV_IP , RECV_UNIX , RECV_SOCKET }

## Functions
VALUE | rsock_sockaddr_string_value (volatile VALUE *)
char * | rsock_sockaddr_string_value_ptr (volatile VALUE *)
VALUE | rsock_sockaddr_string_value_with_addrinfo (volatile VALUE *v, VALUE *ai_ret)
VALUE | rb_check_sockaddr_string_type (VALUE)
void | rsock_raise_socket_error (const char *, int)
int | rsock_family_arg (VALUE domain)
int | rsock_socktype_arg (VALUE type)
int | rsock_level_arg (int family, VALUE level)
int | rsock_optname_arg (int family, int level, VALUE optname)
int | rsock_cmsg_type_arg (int family, int level, VALUE type)
int | rsock_shutdown_how_arg (VALUE how)
int | rsock_getfamily (rb_io_t *fptr)
int | rb_getaddrinfo (const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res)
void | rb_freeaddrinfo (struct rb_addrinfo *ai)
VALUE | rsock_freeaddrinfo (VALUE arg)
int | rb_getnameinfo (const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
int | rsock_fd_family (int fd)
struct rb_addrinfo * | rsock_addrinfo (VALUE host, VALUE port, int family, int socktype, int flags)
struct rb_addrinfo * | rsock_getaddrinfo (VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
VALUE | rsock_fd_socket_addrinfo (int fd, struct sockaddr *addr, socklen_t len)
VALUE | rsock_io_socket_addrinfo (VALUE io, struct sockaddr *addr, socklen_t len)
VALUE | rsock_addrinfo_new (struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname)
VALUE | rsock_addrinfo_inspect_sockaddr (VALUE rai)
VALUE | rsock_make_ipaddr (struct sockaddr *addr, socklen_t addrlen)
VALUE | rsock_ipaddr (struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
VALUE | rsock_make_hostent (VALUE host, struct rb_addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, socklen_t))
VALUE | rsock_inspect_sockaddr (struct sockaddr *addr, socklen_t socklen, VALUE ret)
socklen_t | rsock_sockaddr_len (struct sockaddr *addr)
VALUE | rsock_sockaddr_obj (struct sockaddr *addr, socklen_t len)
int | rsock_revlookup_flag (VALUE revlookup, int *norevlookup)
int | rsock_socket (int domain, int type, int proto)
int | rsock_detect_cloexec (int fd)
VALUE | rsock_init_sock (VALUE sock, int fd)
VALUE | rsock_sock_s_socketpair (int argc, VALUE *argv, VALUE klass)
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)
VALUE | rsock_init_unixsock (VALUE sock, VALUE path, int server)
VALUE | rsock_sendto_blocking (void *data)
VALUE | rsock_send_blocking (void *data)
VALUE | rsock_bsock_send (int argc, VALUE *argv, VALUE sock)
VALUE | rsock_s_recvfrom_nonblock (VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex, enum sock_recv_type from)
VALUE | rsock_s_recvfrom (VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
int | rsock_connect (int fd, const struct sockaddr *sockaddr, int len, int socks, struct timeval *timeout)
VALUE | rsock_s_accept (VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
VALUE | rsock_s_accept_nonblock (VALUE klass, VALUE ex, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
VALUE | rsock_sock_listen (VALUE sock, VALUE log)
VALUE | rsock_sockopt_new (int family, int level, int optname, VALUE data)
void | rsock_init_basicsocket (void)
void | rsock_init_ipsocket (void)
void | rsock_init_tcpsocket (void)
void | rsock_init_tcpserver (void)
void | rsock_init_sockssocket (void)
void | rsock_init_udpsocket (void)
void | rsock_init_unixsocket (void)
void | rsock_init_unixserver (void)
void | rsock_init_socket_constants (void)
void | rsock_init_ancdata (void)
void | rsock_init_addrinfo (void)
void | rsock_init_sockopt (void)
void | rsock_init_sockifaddr (void)
void | rsock_init_socket_init (void)
void | rsock_syserr_fail_host_port (int err, const char *, VALUE, VALUE)
void | rsock_syserr_fail_path (int err, const char *, VALUE)
void | rsock_syserr_fail_sockaddr (int err, const char *mesg, struct sockaddr *addr, socklen_t len)
void | rsock_syserr_fail_raddrinfo (int err, const char *mesg, VALUE rai)
void | rsock_syserr_fail_raddrinfo_or_sockaddr (int err, const char *mesg, VALUE addr, VALUE rai)
void | rsock_sys_fail_host_port (const char *, VALUE, VALUE)
void | rsock_sys_fail_path (const char *, VALUE)
void | rsock_sys_fail_sockaddr (const char *, struct sockaddr *addr, socklen_t len)
void | rsock_sys_fail_raddrinfo (const char *, VALUE rai)
void | rsock_sys_fail_raddrinfo_or_sockaddr (const char *, VALUE addr, VALUE rai)
VALUE | rsock_read_nonblock (VALUE sock, VALUE length, VALUE buf, VALUE ex)
VALUE | rsock_write_nonblock (VALUE sock, VALUE buf, VALUE ex)
void | rsock_make_fd_nonblock (int fd)
const char * | inet_ntop (int, const void *, char *, size_t)

## Variables
int | rsock_do_not_reverse_lookup
VALUE | rb_cBasicSocket
VALUE | rb_cIPSocket
VALUE | rb_cTCPSocket
VALUE | rb_cTCPServer
VALUE | rb_cUDPSocket
VALUE | rb_cSocket
VALUE | rb_cAddrinfo
VALUE | rb_cSockOpt
VALUE | rb_eSocket

## Macro Definition Documentation

## ◆ _SS_ALIGNSIZE

#define _SS_ALIGNSIZE (sizeof(double))

Definition at line 199 of file rubysocket.h.

## ◆ _SS_MAXSIZE

#define _SS_MAXSIZE 128

Definition at line 198 of file rubysocket.h.

## ◆ _SS_PAD1SIZE

#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)

Definition at line 200 of file rubysocket.h.

## ◆ _SS_PAD2SIZE

#define _SS_PAD2SIZE

Value:
(_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)
_SS_ALIGNSIZE
#define _SS_ALIGNSIZE
Definition: rubysocket.h:199
_SS_MAXSIZE
#define _SS_MAXSIZE
Definition: rubysocket.h:198
_SS_PAD1SIZE
#define _SS_PAD1SIZE
Definition: rubysocket.h:200

Definition at line 201 of file rubysocket.h.

## ◆ BLOCKING_REGION_FD

#define BLOCKING_REGION_FD | ( |  | func,
|  |  | arg
| ) |  | (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)

Definition at line 290 of file rubysocket.h.

## ◆ EWOULDBLOCK

#define EWOULDBLOCK EAGAIN

Definition at line 164 of file rubysocket.h.

## ◆ FMODE_INET

#define FMODE_INET 0x00400000

Definition at line 261 of file rubysocket.h.

## ◆ FMODE_INET6

#define FMODE_INET6 0x00800000

Definition at line 262 of file rubysocket.h.

## ◆ FMODE_NOREVLOOKUP

#define FMODE_NOREVLOOKUP 0x100

Definition at line 257 of file rubysocket.h.

## ◆ FMODE_SOCK

#define FMODE_SOCK (FMODE_UNIX|FMODE_INET|FMODE_INET6)

Definition at line 263 of file rubysocket.h.

## ◆ FMODE_UNIX

#define FMODE_UNIX 0x00200000

Definition at line 260 of file rubysocket.h.

## ◆ IN6_IS_ADDR_UNIQUE_LOCAL

#define IN6_IS_ADDR_UNIQUE_LOCAL | ( |  | a | ) | (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))

Definition at line 191 of file rubysocket.h.

## ◆ INET_CLIENT

#define INET_CLIENT 0

Definition at line 252 of file rubysocket.h.

## ◆ INET_SERVER

#define INET_SERVER 1

Definition at line 253 of file rubysocket.h.

## ◆ INET_SOCKS

#define INET_SOCKS 2

Definition at line 254 of file rubysocket.h.

## ◆ IS_IP_FAMILY

#define IS_IP_FAMILY | ( |  | af | ) | ((af) == AF_INET)

Definition at line 187 of file rubysocket.h.

## ◆ MSG_DONTWAIT_RELIABLE

#define MSG_DONTWAIT_RELIABLE 0

Definition at line 459 of file rubysocket.h.

## ◆ pseudo_AF_FTIP

#define pseudo_AF_FTIP pseudo_AF_RTIP

Definition at line 174 of file rubysocket.h.

## ◆ rsock_bsock_recvmsg

#define rsock_bsock_recvmsg rb_f_notimplement

Definition at line 400 of file rubysocket.h.

## ◆ rsock_bsock_recvmsg_nonblock

#define rsock_bsock_recvmsg_nonblock rb_f_notimplement

Definition at line 401 of file rubysocket.h.

## ◆ rsock_bsock_sendmsg

#define rsock_bsock_sendmsg rb_f_notimplement

Definition at line 389 of file rubysocket.h.

## ◆ rsock_bsock_sendmsg_nonblock

#define rsock_bsock_sendmsg_nonblock rb_f_notimplement

Definition at line 390 of file rubysocket.h.

## ◆ rsock_maybe_fd_writable

#define rsock_maybe_fd_writable | ( |  | fd | ) | rb_thread_fd_writable((fd))

Definition at line 450 of file rubysocket.h.

## ◆ rsock_maybe_wait_fd

#define rsock_maybe_wait_fd | ( |  | fd | ) | rb_thread_wait_fd((fd))

Definition at line 451 of file rubysocket.h.

## ◆ RSTRING_SOCKLEN

#define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT

Definition at line 160 of file rubysocket.h.

## ◆ SockAddrStringValue

#define SockAddrStringValue | ( |  | v | ) | rsock_sockaddr_string_value(&(v))

Definition at line 292 of file rubysocket.h.

## ◆ SockAddrStringValuePtr

#define SockAddrStringValuePtr | ( |  | v | ) | rsock_sockaddr_string_value_ptr(&(v))

Definition at line 293 of file rubysocket.h.

## ◆ SockAddrStringValueWithAddrinfo

#define SockAddrStringValueWithAddrinfo | ( |  | v,
|  |  | rai_ret
| ) |  | rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))

Definition at line 294 of file rubysocket.h.

## ◆ SOCKLEN_MAX

#define SOCKLEN_MAX

Value:
(0 < (socklen_t)-1 ? \
~(socklen_t)0 : \
(((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
socklen_t
int socklen_t
Definition: getaddrinfo.c:83
CHAR_BIT
#define CHAR_BIT
Definition: limits.h:44
socklen_t
int socklen_t
Definition: rubysocket.h:144

Definition at line 154 of file rubysocket.h.

## Typedef Documentation

## ◆ socklen_t

typedef int socklen_t

Definition at line 144 of file rubysocket.h.

## Enumeration Type Documentation

## ◆ sock_recv_type

enum sock_recv_type

Enumerator
RECV_RECV |
RECV_IP |
RECV_UNIX |
RECV_SOCKET |

Definition at line 363 of file rubysocket.h.

## Function Documentation

## ◆ inet_ntop()

const char * inet_ntop | ( | int | af,
|  | const void * | addr,
|  | char * | numaddr,
|  | size_t | numaddr_len
| ) |  |

Definition at line 651 of file option.c.

References in(), memcpy, and snprintf.

Referenced by getnameinfo().

## ◆ rb_check_sockaddr_string_type()

VALUE rb_check_sockaddr_string_type | ( | VALUE | val | ) |

Definition at line 2510 of file raddrinfo.c.

References IS_ADDRINFO, and rb_check_string_type().

## ◆ rb_freeaddrinfo()

void rb_freeaddrinfo | ( | struct rb_addrinfo * | ai | ) |

Definition at line 322 of file raddrinfo.c.

References rb_addrinfo::ai, addrinfo::ai_addr, addrinfo::ai_next, freeaddrinfo, and xfree.

Referenced by rsock_freeaddrinfo().

## ◆ rb_getaddrinfo()

int rb_getaddrinfo | ( | const char * | node,
|  | const char * | service,
|  | const struct addrinfo * | hints,
|  | struct rb_addrinfo ** | res
| ) |  |

Definition at line 288 of file raddrinfo.c.

References rb_addrinfo::ai, rb_addrinfo::allocated_by_malloc, getaddrinfo, getaddrinfo_arg::hints, int(), MEMZERO, getaddrinfo_arg::node, rb_thread_call_without_gvl(), getaddrinfo_arg::res, RUBY_UBF_IO, getaddrinfo_arg::service, and xmalloc.

Referenced by rsock_getaddrinfo().

## ◆ 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 at line 363 of file raddrinfo.c.

References getnameinfo_arg::flags, getnameinfo, getnameinfo_arg::host, getnameinfo_arg::hostlen, int(), rb_thread_call_without_gvl(), RUBY_UBF_IO, getnameinfo_arg::sa, getnameinfo_arg::salen, getnameinfo_arg::serv, and getnameinfo_arg::servlen.

Referenced by rsock_ipaddr().

## ◆ rsock_addrinfo()

struct rb_addrinfo * rsock_addrinfo | ( | VALUE | host,
|  | VALUE | port,
|  | int | family,
|  | int | socktype,
|  | int | flags
| ) |  |

Definition at line 543 of file raddrinfo.c.

References addrinfo::ai_family, addrinfo::ai_flags, addrinfo::ai_socktype, MEMZERO, and rsock_getaddrinfo().

## ◆ rsock_addrinfo_inspect_sockaddr()

VALUE rsock_addrinfo_inspect_sockaddr | ( | VALUE | rai | ) |

Definition at line 1523 of file raddrinfo.c.

References rb_str_new.

Referenced by rsock_init_addrinfo(), and rsock_syserr_fail_raddrinfo().

## ◆ rsock_addrinfo_new()

VALUE rsock_addrinfo_new | ( | struct sockaddr * | addr,
|  | socklen_t | len,
|  | int | family,
|  | int | socktype,
|  | int | protocol,
|  | VALUE | canonname,
|  | VALUE | inspectname
| ) |  |

Definition at line 800 of file raddrinfo.c.

References DATA_PTR, len, and rb_cAddrinfo.

Referenced by rsock_fd_socket_addrinfo(), and rsock_syserr_fail_sockaddr().

## ◆ rsock_bsock_send()

VALUE rsock_bsock_send | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | sock
| ) |  |

Definition at line 540 of file basicsocket.c.

References argc, argv, BLOCKING_REGION_FD, rsock_send_arg::fd, rb_io_t::fd, rsock_send_arg::flags, GetOpenFile, rsock_send_arg::mesg, NIL_P, NUM2INT, rb_io_wait_writable(), rb_scan_args(), rb_str_new4, rb_sys_fail(), rsock_maybe_fd_writable, rsock_send_blocking(), rsock_sendto_blocking(), RSTRING_PTR, RSTRING_SOCKLEN, SockAddrStringValue, SSIZET2NUM, StringValue, rsock_send_arg::to, and rsock_send_arg::tolen.

Referenced by rsock_init_basicsocket().

## ◆ rsock_cmsg_type_arg()

int rsock_cmsg_type_arg | ( | int | family,
|  | int | level,
|  | VALUE | type
| ) |  |

Definition at line 99 of file constants.c.

References IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP, IS_IP_FAMILY, NUM2INT, rsock_ip_optname_to_int(), rsock_scm_optname_to_int(), rsock_tcp_optname_to_int(), and rsock_udp_optname_to_int().

## ◆ rsock_connect()

int rsock_connect | ( | int | fd,
|  | const struct sockaddr * | sockaddr,
|  | int | len,
|  | int | socks,
|  | struct timeval * | timeout
| ) |  |

Definition at line 559 of file init.c.

References BLOCKING_REGION_FD, EINPROGRESS, connect_arg::fd, int(), len, connect_arg::len, and connect_arg::sockaddr.

## ◆ rsock_detect_cloexec()

int rsock_detect_cloexec | ( | int | fd | ) |

## ◆ rsock_family_arg()

int rsock_family_arg | ( | VALUE | domain | ) |

Definition at line 42 of file constants.c.

References rsock_family_to_int().

## ◆ rsock_fd_family()

int rsock_fd_family | ( | int | fd | ) |

Definition at line 530 of file raddrinfo.c.

References AF_UNSPEC, and offsetof.

## ◆ rsock_fd_socket_addrinfo()

VALUE rsock_fd_socket_addrinfo | ( | int | fd,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 2518 of file raddrinfo.c.

References len, Qnil, rb_sys_fail(), and rsock_addrinfo_new().

Referenced by rsock_io_socket_addrinfo().

## ◆ rsock_freeaddrinfo()

VALUE rsock_freeaddrinfo | ( | VALUE | arg | ) |

Definition at line 698 of file raddrinfo.c.

References Qnil, and rb_freeaddrinfo().

Referenced by rsock_make_hostent().

## ◆ rsock_getaddrinfo()

struct rb_addrinfo * rsock_getaddrinfo | ( | VALUE | host,
|  | VALUE | port,
|  | struct addrinfo * | hints,
|  | int | socktype_hack
| ) |  |

Definition at line 502 of file raddrinfo.c.

References addrinfo::ai_flags, addrinfo::ai_socktype, error(), NI_MAXHOST, NI_MAXSERV, NULL, rb_eSocket, rb_getaddrinfo(), rb_raise(), rsock_raise_socket_error(), and strlen().

Referenced by rsock_addrinfo().

## ◆ rsock_getfamily()

int rsock_getfamily | ( | rb_io_t * | fptr | ) |

Definition at line 720 of file init.c.

References union_sockaddr::addr, AF_UNSPEC, rb_io_t::fd, FMODE_INET, FMODE_INET6, FMODE_SOCK, FMODE_UNIX, and rb_io_t::mode.

## ◆ rsock_init_addrinfo()

void rsock_init_addrinfo | ( | void |  | ) |

Definition at line 2563 of file raddrinfo.c.

References rb_cAddrinfo, rb_cObject, rb_define_alloc_func(), rb_define_class(), rb_define_method, rb_define_singleton_method, rb_intern(), and rsock_addrinfo_inspect_sockaddr().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_ancdata()

void rsock_init_ancdata | ( | void |  | ) |

Definition at line 1693 of file ancdata.c.

References ID2SYM, rb_cObject, rb_cSocket, rb_define_class_under(), rb_define_method, rb_define_singleton_method, and rb_intern().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_basicsocket()

void rsock_init_basicsocket | ( | void |  | ) |

Definition at line 704 of file basicsocket.c.

References bsock_getpeereid, rb_cBasicSocket, rb_cIO, rb_define_class(), rb_define_method, rb_define_private_method, rb_define_singleton_method, rb_undef_method(), rsock_bsock_recvmsg, rsock_bsock_recvmsg_nonblock, rsock_bsock_send(), rsock_bsock_sendmsg, rsock_bsock_sendmsg_nonblock, rsock_read_nonblock(), and rsock_write_nonblock().

Referenced by Init_socket().

## ◆ 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 at line 171 of file ipsocket.c.

References inetsock_arg::connect_timeout, inetsock_arg::fd, inetsock_arg::host, inetsock_arg::local, rb_ensure(), inetsock_arg::remote, inetsock_arg::res, inetsock_arg::resolv_timeout, inetsock_arg::serv, inetsock_arg::sock, and inetsock_arg::type.

## ◆ rsock_init_ipsocket()

void rsock_init_ipsocket | ( | void |  | ) |

Definition at line 386 of file ipsocket.c.

References rb_cBasicSocket, rb_cIPSocket, rb_define_class(), rb_define_method, rb_define_singleton_method, and rb_undef_method().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_sock()

VALUE rsock_init_sock | ( | VALUE | sock,
|  | int | fd
| ) |  |

Definition at line 78 of file init.c.

References rb_io_t::fd, FMODE_DUPLEX, FMODE_NOREVLOOKUP, FMODE_READWRITE, is_socket, MakeOpenFile, rb_io_t::mode, rb_io_ascii8bit_binmode(), rb_io_synchronized(), rb_reserved_fd_p(), rb_syserr_fail(), rb_update_max_fd(), and rsock_do_not_reverse_lookup.

Referenced by rsock_s_accept(), and rsock_s_accept_nonblock().

## ◆ rsock_init_socket_constants()

void rsock_init_socket_constants | ( | void |  | ) |

Definition at line 140 of file constants.c.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_socket_init()

void rsock_init_socket_init | ( | void |  | ) |

Definition at line 752 of file init.c.

References ID2SYM, rb_define_class(), rb_eSocket, rb_eStandardError, rb_intern(), rsock_init_addrinfo(), rsock_init_ancdata(), rsock_init_ipsocket(), rsock_init_socket_constants(), rsock_init_sockifaddr(), rsock_init_sockopt(), rsock_init_sockssocket(), rsock_init_tcpserver(), rsock_init_tcpsocket(), rsock_init_udpsocket(), rsock_init_unixserver(), and rsock_init_unixsocket().

Referenced by Init_socket().

## ◆ rsock_init_sockifaddr()

void rsock_init_sockifaddr | ( | void |  | ) |

Definition at line 454 of file ifaddr.c.

References rb_cObject, rb_cSocket, rb_define_class_under(), rb_define_method, rb_define_singleton_method, rb_undef_alloc_func(), and socket_s_getifaddrs.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_sockopt()

void rsock_init_sockopt | ( | void |  | ) |

Definition at line 1438 of file option.c.

References rb_cObject, rb_cSocket, rb_cSockOpt, rb_define_class_under(), rb_define_method, and rb_define_singleton_method.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_sockssocket()

void rsock_init_sockssocket | ( | void |  | ) |

Definition at line 58 of file sockssocket.c.

References rb_cTCPSocket, rb_define_class(), and rb_define_method.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_tcpserver()

void rsock_init_tcpserver | ( | void |  | ) |

Definition at line 106 of file tcpserver.c.

References rb_cTCPServer, rb_cTCPSocket, rb_define_class(), rb_define_method, rb_define_private_method, and rsock_sock_listen().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_tcpsocket()

void rsock_init_tcpsocket | ( | void |  | ) |

Definition at line 88 of file tcpsocket.c.

References rb_cIPSocket, rb_cTCPSocket, rb_define_class(), rb_define_method, and rb_define_singleton_method.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_udpsocket()

void rsock_init_udpsocket | ( | void |  | ) |

Definition at line 230 of file udpsocket.c.

References rb_cIPSocket, rb_cUDPSocket, rb_define_class(), rb_define_method, and rb_define_private_method.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_unixserver()

void rsock_init_unixserver | ( | void |  | ) |

Definition at line 109 of file unixserver.c.

References rb_define_class(), rb_define_method, rb_define_private_method, and rsock_sock_listen().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_unixsock()

VALUE rsock_init_unixsock | ( | VALUE | sock,
|  | VALUE | path,
|  | int | server
| ) |  |

## ◆ rsock_init_unixsocket()

void rsock_init_unixsocket | ( | void |  | ) |

Definition at line 572 of file unixsocket.c.

References rb_cBasicSocket, rb_define_class(), rb_define_method, and rb_define_singleton_method.

Referenced by rsock_init_socket_init().

## ◆ rsock_inspect_sockaddr()

VALUE rsock_inspect_sockaddr | ( | struct sockaddr * | addr,
|  | socklen_t | socklen,
|  | VALUE | ret
| ) |  |

Definition at line 1148 of file raddrinfo.c.

References union_sockaddr::addr, AF_UNSPEC, error(), getnameinfo, IFNAMSIZ, union_sockaddr::in, int(), ISPRINT, ISSPACE, len, NI_NUMERICHOST, NI_NUMERICSERV, NULL, offsetof, rb_id2name(), rb_str_cat(), rb_str_cat2, rb_str_catf(), rsock_intern_family(), and rsock_raise_socket_error().

## ◆ rsock_io_socket_addrinfo()

VALUE rsock_io_socket_addrinfo | ( | VALUE | io,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 2537 of file raddrinfo.c.

References rb_io_t::fd, FIX2INT, GetOpenFile, len, NUM2INT, Qnil, rb_eTypeError, rb_raise(), rsock_fd_socket_addrinfo(), T_BIGNUM, T_FILE, T_FIXNUM, TYPE, and UNREACHABLE_RETURN.

Referenced by rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rsock_ipaddr()

VALUE rsock_ipaddr | ( | struct sockaddr * | sockaddr,
|  | socklen_t | sockaddrlen,
|  | int | norevlookup
| ) |  |

Definition at line 555 of file raddrinfo.c.

References error(), id, INT2FIX, NI_NUMERICHOST, NI_NUMERICSERV, NULL, Qnil, rb_ary_new3, rb_getnameinfo(), rb_id2str, rb_str_dup(), rb_str_new2, rsock_intern_family(), and rsock_raise_socket_error().

Referenced by rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().

## ◆ rsock_level_arg()

int rsock_level_arg | ( | int | family,
|  | VALUE | level
| ) |  |

Definition at line 56 of file constants.c.

References IS_IP_FAMILY, rsock_ip_level_to_int(), and rsock_unknown_level_to_int().

## ◆ rsock_make_fd_nonblock()

void rsock_make_fd_nonblock | ( | int | fd | ) |

Definition at line 590 of file init.c.

References F_SETFL, fcntl(), connect_arg::fd, O_NONBLOCK, and rb_sys_fail().

## ◆ rsock_make_hostent()

VALUE rsock_make_hostent | ( | VALUE | host,
|  | struct rb_addrinfo * | addr,
|  | VALUE(*)(struct sockaddr *, socklen_t) | ipaddr
| ) |  |

Definition at line 706 of file raddrinfo.c.

References hostent_arg::addr, hostent_arg::host, hostent_arg::ipaddr, rb_ensure(), and rsock_freeaddrinfo().

## ◆ rsock_make_ipaddr()

VALUE rsock_make_ipaddr | ( | struct sockaddr * | addr,
|  | socklen_t | addrlen
| ) |  |

Definition at line 396 of file raddrinfo.c.

References rb_str_new2.

## ◆ rsock_optname_arg()

int rsock_optname_arg | ( | int | family,
|  | int | level,
|  | VALUE | optname
| ) |  |

Definition at line 68 of file constants.c.

References IPPROTO_IP, IPPROTO_TCP, IPPROTO_UDP, IS_IP_FAMILY, NUM2INT, rsock_ip_optname_to_int(), rsock_so_optname_to_int(), rsock_tcp_optname_to_int(), and rsock_udp_optname_to_int().

## ◆ rsock_raise_socket_error()

void rsock_raise_socket_error | ( | const char * | reason,
|  | int | error
| ) |  |

Definition at line 39 of file init.c.

References EAI_SYSTEM, error(), gai_strerror(), rb_default_internal_encoding(), rb_eSocket, rb_exc_new_str(), rb_exc_raise(), rb_raise(), rb_sprintf(), rb_str_concat(), rb_syserr_fail(), and rb_w32_conv_from_wchar().

Referenced by rsock_getaddrinfo(), rsock_inspect_sockaddr(), and rsock_ipaddr().

## ◆ rsock_read_nonblock()

VALUE rsock_read_nonblock | ( | VALUE | sock,
|  | VALUE | length,
|  | VALUE | buf,
|  | VALUE | ex
| ) |  |

Referenced by rsock_init_basicsocket().

## ◆ rsock_revlookup_flag()

int rsock_revlookup_flag | ( | VALUE | revlookup,
|  | int * | norevlookup
| ) |  |

Definition at line 194 of file ipsocket.c.

References id, Qfalse, Qnil, Qtrue, rb_eArgError, rb_id2name(), rb_raise(), return_norevlookup, SYM2ID, and T_SYMBOL.

## ◆ rsock_s_accept()

VALUE rsock_s_accept | ( | VALUE | klass,
|  | int | fd,
|  | struct sockaddr * | sockaddr,
|  | socklen_t * | len
| ) |  |

Definition at line 685 of file init.c.

References BLOCKING_REGION_FD, accept_arg::fd, int(), INT2NUM, len, accept_arg::len, rb_gc(), rb_io_wait_readable(), rb_obj_alloc(), rb_syserr_fail(), rb_update_max_fd(), rsock_init_sock(), rsock_maybe_wait_fd, and accept_arg::sockaddr.

## ◆ rsock_s_accept_nonblock()

VALUE rsock_s_accept_nonblock | ( | VALUE | klass,
|  | VALUE | ex,
|  | rb_io_t * | fptr,
|  | struct sockaddr * | sockaddr,
|  | socklen_t * | len
| ) |  |

Definition at line 643 of file init.c.

References ECONNABORTED, EWOULDBLOCK, rb_io_t::fd, len, Qfalse, rb_io_set_nonblock(), RB_IO_WAIT_READABLE, rb_obj_alloc(), rb_readwrite_syserr_fail(), rb_syserr_fail(), rb_update_max_fd(), rsock_init_sock(), and connect_arg::sockaddr.

## ◆ rsock_s_recvfrom()

VALUE rsock_s_recvfrom | ( | VALUE | sock,
|  | int | argc,
|  | VALUE * | argv,
|  | enum sock_recv_type | from
| ) |  |

Definition at line 169 of file init.c.

References union_sockaddr::addr, recvfrom_arg::alen, argc, argv, recvfrom_arg::buf, recvfrom_arg::fd, rb_io_t::fd, recvfrom_arg::flags, FMODE_NOREVLOOKUP, GetOpenFile, len, recvfrom_arg::length, long(), rb_io_t::mode, NUM2INT, Qnil, rb_assoc_new(), rb_bug(), rb_eIOError, rb_eTypeError, rb_io_check_closed(), rb_io_read_pending(), rb_io_wait_readable(), rb_raise(), rb_scan_args(), rb_str_locktmp_ensure(), rb_str_set_len(), rb_sys_fail(), RECV_IP, RECV_RECV, RECV_SOCKET, RECV_UNIX, rsock_io_socket_addrinfo(), rsock_ipaddr(), rsock_maybe_wait_fd, str, and recvfrom_arg::str.

## ◆ 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 at line 231 of file init.c.

References recvfrom_arg::alen, EWOULDBLOCK, recvfrom_arg::fd, rb_io_t::fd, recvfrom_arg::flags, FMODE_NOREVLOOKUP, GetOpenFile, len, rb_io_t::mode, MSG_DONTWAIT_RELIABLE, NUM2INT, Qfalse, Qnil, rb_assoc_new(), rb_bug(), rb_eIOError, rb_io_check_closed(), rb_io_read_pending(), rb_io_set_nonblock(), RB_IO_WAIT_READABLE, rb_raise(), rb_readwrite_syserr_fail(), rb_str_set_len(), rb_syserr_fail(), RECV_IP, RECV_RECV, RECV_SOCKET, rsock_io_socket_addrinfo(), rsock_ipaddr(), RSTRING_LEN, RSTRING_PTR, and str.

## ◆ rsock_send_blocking()

VALUE rsock_send_blocking | ( | void * | data | ) |

Definition at line 111 of file init.c.

References do_write_retry, rsock_send_arg::fd, rsock_send_arg::flags, rsock_send_arg::mesg, RSTRING_LEN, and RSTRING_PTR.

Referenced by rsock_bsock_send().

## ◆ rsock_sendto_blocking()

VALUE rsock_sendto_blocking | ( | void * | data | ) |

Definition at line 100 of file init.c.

References do_write_retry, rsock_send_arg::fd, rsock_send_arg::flags, rsock_send_arg::mesg, RSTRING_LEN, RSTRING_PTR, rsock_send_arg::to, and rsock_send_arg::tolen.

Referenced by rsock_bsock_send().

## ◆ rsock_shutdown_how_arg()

int rsock_shutdown_how_arg | ( | VALUE | how | ) |

Definition at line 130 of file constants.c.

References rsock_shutdown_how_to_int().

## ◆ rsock_sock_listen()

VALUE rsock_sock_listen | ( | VALUE | sock,
|  | VALUE | log
| ) |  |

Definition at line 607 of file socket.c.

References rb_io_t::fd, GetOpenFile, INT2FIX, NUM2INT, and rb_sys_fail().

Referenced by Init_socket(), rsock_init_tcpserver(), and rsock_init_unixserver().

## ◆ rsock_sock_s_socketpair()

VALUE rsock_sock_s_socketpair | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass
| ) |  |

## ◆ rsock_sockaddr_len()

socklen_t rsock_sockaddr_len | ( | struct sockaddr * | addr | ) |

## ◆ rsock_sockaddr_obj()

VALUE rsock_sockaddr_obj | ( | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

## ◆ rsock_sockaddr_string_value()

VALUE rsock_sockaddr_string_value | ( | volatile VALUE * | v | ) |

Definition at line 2479 of file raddrinfo.c.

References IS_ADDRINFO, and StringValue.

Referenced by rsock_sockaddr_string_value_ptr().

## ◆ rsock_sockaddr_string_value_ptr()

char * rsock_sockaddr_string_value_ptr | ( | volatile VALUE * | v | ) |

Definition at line 2503 of file raddrinfo.c.

References rsock_sockaddr_string_value(), and RSTRING_PTR.

## ◆ rsock_sockaddr_string_value_with_addrinfo()

VALUE rsock_sockaddr_string_value_with_addrinfo | ( | volatile VALUE * | v,
|  | VALUE * | ai_ret
| ) |  |

Definition at line 2490 of file raddrinfo.c.

References IS_ADDRINFO, Qnil, and StringValue.

## ◆ rsock_socket()

int rsock_socket | ( | int | domain,
|  | int | type,
|  | int | proto
| ) |  |

Definition at line 437 of file init.c.

References recvfrom_arg::fd, rb_gc_for_fd(), and rb_update_max_fd().

## ◆ rsock_sockopt_new()

VALUE rsock_sockopt_new | ( | int | family,
|  | int | level,
|  | int | optname,
|  | VALUE | data
| ) |  |

Definition at line 107 of file option.c.

References INT2NUM, rb_cSockOpt, rb_obj_alloc(), and StringValue.

## ◆ rsock_socktype_arg()

int rsock_socktype_arg | ( | VALUE | type | ) |

Definition at line 49 of file constants.c.

References rsock_socktype_to_int().

## ◆ rsock_sys_fail_host_port()

void rsock_sys_fail_host_port | ( | const char * | mesg,
|  | VALUE | host,
|  | VALUE | port
| ) |  |

Definition at line 18 of file socket.c.

References rsock_syserr_fail_host_port().

## ◆ rsock_sys_fail_path()

void rsock_sys_fail_path | ( | const char * | mesg,
|  | VALUE | path
| ) |  |

Definition at line 35 of file socket.c.

References rsock_syserr_fail_path().

## ◆ rsock_sys_fail_raddrinfo()

void rsock_sys_fail_raddrinfo | ( | const char * | mesg,
|  | VALUE | rai
| ) |  |

Definition at line 71 of file socket.c.

References rsock_syserr_fail_raddrinfo().

## ◆ rsock_sys_fail_raddrinfo_or_sockaddr()

void rsock_sys_fail_raddrinfo_or_sockaddr | ( | const char * | mesg,
|  | VALUE | addr,
|  | VALUE | rai
| ) |  |

Definition at line 88 of file socket.c.

References rsock_syserr_fail_raddrinfo_or_sockaddr().

## ◆ rsock_sys_fail_sockaddr()

void rsock_sys_fail_sockaddr | ( | const char * | mesg,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 55 of file socket.c.

References len, and rsock_syserr_fail_sockaddr().

## ◆ rsock_syserr_fail_host_port()

void rsock_syserr_fail_host_port | ( | int | err,
|  | const char * | mesg,
|  | VALUE | host,
|  | VALUE | port
| ) |  |

Definition at line 24 of file socket.c.

References err, PRIsVALUE, rb_sprintf(), and rb_syserr_fail_str().

Referenced by rsock_sys_fail_host_port().

## ◆ rsock_syserr_fail_path()

void rsock_syserr_fail_path | ( | int | err,
|  | const char * | mesg,
|  | VALUE | path
| ) |  |

Definition at line 41 of file socket.c.

References err, PRIsVALUE, rb_sprintf(), rb_syserr_fail(), rb_syserr_fail_str(), and T_STRING.

Referenced by rsock_sys_fail_path().

## ◆ rsock_syserr_fail_raddrinfo()

void rsock_syserr_fail_raddrinfo | ( | int | err,
|  | const char * | mesg,
|  | VALUE | rai
| ) |  |

Definition at line 77 of file socket.c.

References err, PRIsVALUE, rb_sprintf(), rb_syserr_fail_str(), rsock_addrinfo_inspect_sockaddr(), and str.

Referenced by rsock_sys_fail_raddrinfo(), rsock_syserr_fail_raddrinfo_or_sockaddr(), and rsock_syserr_fail_sockaddr().

## ◆ rsock_syserr_fail_raddrinfo_or_sockaddr()

void rsock_syserr_fail_raddrinfo_or_sockaddr | ( | int | err,
|  | const char * | mesg,
|  | VALUE | addr,
|  | VALUE | rai
| ) |  |

Definition at line 94 of file socket.c.

References err, NIL_P, rsock_syserr_fail_raddrinfo(), rsock_syserr_fail_sockaddr(), RSTRING_LEN, RSTRING_PTR, and StringValue.

Referenced by rsock_sys_fail_raddrinfo_or_sockaddr().

## ◆ rsock_syserr_fail_sockaddr()

void rsock_syserr_fail_sockaddr | ( | int | err,
|  | const char * | mesg,
|  | struct sockaddr * | addr,
|  | socklen_t | len
| ) |  |

Definition at line 61 of file socket.c.

References err, len, PF_UNSPEC, Qnil, rsock_addrinfo_new(), and rsock_syserr_fail_raddrinfo().

Referenced by rsock_sys_fail_sockaddr(), and rsock_syserr_fail_raddrinfo_or_sockaddr().

## ◆ rsock_write_nonblock()

VALUE rsock_write_nonblock | ( | VALUE | sock,
|  | VALUE | buf,
|  | VALUE | ex
| ) |  |

Referenced by rsock_init_basicsocket().

## Variable Documentation

## ◆ rb_cAddrinfo

VALUE rb_cAddrinfo
| extern

Definition at line 27 of file init.c.

Referenced by rsock_addrinfo_new(), and rsock_init_addrinfo().

## ◆ rb_cBasicSocket

VALUE rb_cBasicSocket
| extern

Definition at line 17 of file init.c.

Referenced by Init_socket(), rsock_init_basicsocket(), rsock_init_ipsocket(), and rsock_init_unixsocket().

## ◆ rb_cIPSocket

VALUE rb_cIPSocket
| extern

Definition at line 18 of file init.c.

Referenced by rsock_init_ipsocket(), rsock_init_tcpsocket(), and rsock_init_udpsocket().

## ◆ rb_cSocket

VALUE rb_cSocket
| extern

Definition at line 26 of file init.c.

Referenced by Init_socket(), rsock_init_ancdata(), rsock_init_sockifaddr(), and rsock_init_sockopt().

## ◆ rb_cSockOpt

VALUE rb_cSockOpt
| extern

Definition at line 3 of file option.c.

Referenced by rsock_init_sockopt(), and rsock_sockopt_new().

## ◆ rb_cTCPServer

VALUE rb_cTCPServer
| extern

Definition at line 20 of file init.c.

Referenced by rsock_init_tcpserver().

## ◆ rb_cTCPSocket

VALUE rb_cTCPSocket
| extern

Definition at line 19 of file init.c.

Referenced by rsock_init_sockssocket(), rsock_init_tcpserver(), and rsock_init_tcpsocket().

## ◆ rb_cUDPSocket

VALUE rb_cUDPSocket
| extern

Definition at line 21 of file init.c.

Referenced by rsock_init_udpsocket().

## ◆ rb_eSocket

VALUE rb_eSocket
| extern

Definition at line 29 of file init.c.

Referenced by rsock_getaddrinfo(), rsock_init_socket_init(), and rsock_raise_socket_error().

## ◆ rsock_do_not_reverse_lookup

int rsock_do_not_reverse_lookup
| extern

Definition at line 35 of file init.c.

Referenced by rsock_init_sock().