Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
rubysocket.h File Reference
`#include "ruby/ruby.h"`
`#include "ruby/io.h"`
`#include "ruby/thread.h"`
`#include "ruby/util.h"`
`#include "internal.h"`
`#include <stdio.h>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <sys/socket.h>`
`#include <netinet/in.h>`
`#include <netdb.h>`
`#include <errno.h>`
`#include "addrinfo.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 | RSOCK_NONBLOCK_DEFAULT (0)
#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)
| NORETURN (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 | 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)
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)
| NORETURN (void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE))
| NORETURN (void rsock_syserr_fail_path(int err, const char *, VALUE))
| NORETURN (void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len))
| NORETURN (void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai))
| NORETURN (void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai))
| NORETURN (void rsock_sys_fail_host_port(const char *, VALUE, VALUE))
| NORETURN (void rsock_sys_fail_path(const char *, VALUE))
| NORETURN (void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len))
| NORETURN (void rsock_sys_fail_raddrinfo(const char *, VALUE rai))
| NORETURN (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
int | rsock_cmsg_cloexec_state
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 174 of file rubysocket.h.

## ◆ _SS_MAXSIZE

#define _SS_MAXSIZE 128

Definition at line 173 of file rubysocket.h.

## ◆ _SS_PAD1SIZE

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

Definition at line 175 of file rubysocket.h.

## ◆ _SS_PAD2SIZE

#define _SS_PAD2SIZE

Value:
(_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
_SS_PAD1SIZE - _SS_ALIGNSIZE)

Definition at line 176 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 268 of file rubysocket.h.

## ◆ EWOULDBLOCK

#define EWOULDBLOCK EAGAIN

Definition at line 134 of file rubysocket.h.

## ◆ FMODE_INET

#define FMODE_INET 0x00400000

Definition at line 237 of file rubysocket.h.

## ◆ FMODE_INET6

#define FMODE_INET6 0x00800000

Definition at line 238 of file rubysocket.h.

## ◆ FMODE_NOREVLOOKUP

#define FMODE_NOREVLOOKUP 0x100

Definition at line 233 of file rubysocket.h.

## ◆ FMODE_SOCK

#define FMODE_SOCK (FMODE_UNIX|FMODE_INET|FMODE_INET6)

Definition at line 239 of file rubysocket.h.

## ◆ FMODE_UNIX

#define FMODE_UNIX 0x00200000

Definition at line 236 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 166 of file rubysocket.h.

## ◆ INET_CLIENT

#define INET_CLIENT 0

Definition at line 227 of file rubysocket.h.

## ◆ INET_SERVER

#define INET_SERVER 1

Definition at line 228 of file rubysocket.h.

## ◆ INET_SOCKS

#define INET_SOCKS 2

Definition at line 229 of file rubysocket.h.

## ◆ IS_IP_FAMILY

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

Definition at line 162 of file rubysocket.h.

## ◆ MSG_DONTWAIT_RELIABLE

#define MSG_DONTWAIT_RELIABLE 0

Definition at line 436 of file rubysocket.h.

## ◆ pseudo_AF_FTIP

#define pseudo_AF_FTIP pseudo_AF_RTIP

Definition at line 144 of file rubysocket.h.

## ◆ rsock_bsock_recvmsg

#define rsock_bsock_recvmsg rb_f_notimplement

Definition at line 377 of file rubysocket.h.

## ◆ rsock_bsock_recvmsg_nonblock

#define rsock_bsock_recvmsg_nonblock rb_f_notimplement

Definition at line 378 of file rubysocket.h.

## ◆ rsock_bsock_sendmsg

#define rsock_bsock_sendmsg rb_f_notimplement

Definition at line 366 of file rubysocket.h.

## ◆ rsock_bsock_sendmsg_nonblock

#define rsock_bsock_sendmsg_nonblock rb_f_notimplement

Definition at line 367 of file rubysocket.h.

## ◆ rsock_maybe_fd_writable

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

Definition at line 427 of file rubysocket.h.

## ◆ rsock_maybe_wait_fd

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

Definition at line 428 of file rubysocket.h.

## ◆ RSOCK_NONBLOCK_DEFAULT

#define RSOCK_NONBLOCK_DEFAULT (0)

Definition at line 35 of file rubysocket.h.

## ◆ RSTRING_SOCKLEN

#define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT

Definition at line 130 of file rubysocket.h.

## ◆ SockAddrStringValue

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

Definition at line 270 of file rubysocket.h.

## ◆ SockAddrStringValuePtr

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

Definition at line 271 of file rubysocket.h.

## ◆ SockAddrStringValueWithAddrinfo

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

Definition at line 272 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))

Definition at line 124 of file rubysocket.h.

## Typedef Documentation

## ◆ socklen_t

typedef int socklen_t

Definition at line 114 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 340 of file rubysocket.h.

## Function Documentation

## ◆ inet_ntop()

const char* inet_ntop | ( | int | ,
|  | const void * | ,
|  | char * | ,
|  | size_t |
| ) |  |

Definition at line 651 of file option.c.

References memcpy(), and snprintf().

## ◆ NORETURN() [1/11]

NORETURN | ( | void | rsock_raise_socket_errorconst char *, int | ) |

## ◆ NORETURN() [2/11]

NORETURN | ( | void | rsock_sys_fail_host_portconst char *, VALUE, VALUE | ) |

## ◆ NORETURN() [3/11]

NORETURN | ( | void | rsock_sys_fail_pathconst char *, VALUE | ) |

## ◆ NORETURN() [4/11]

NORETURN | ( | void | rsock_sys_fail_raddrinfoconst char *, VALUE rai | ) |

## ◆ NORETURN() [5/11]

NORETURN | ( | void | rsock_sys_fail_raddrinfo_or_sockaddrconst char *, VALUE addr, VALUE rai | ) |

## ◆ NORETURN() [6/11]

NORETURN | ( | void | rsock_sys_fail_sockaddrconst char *, struct sockaddr *addr, socklen_t len | ) |

## ◆ NORETURN() [7/11]

NORETURN | ( | void | rsock_syserr_fail_host_portint err, const char *, VALUE, VALUE | ) |

## ◆ NORETURN() [8/11]

NORETURN | ( | void | rsock_syserr_fail_pathint err, const char *, VALUE | ) |

## ◆ NORETURN() [9/11]

NORETURN | ( | void | rsock_syserr_fail_raddrinfoint err, const char *mesg, VALUE rai | ) |

## ◆ NORETURN() [10/11]

NORETURN | ( | void | rsock_syserr_fail_raddrinfo_or_sockaddrint err, const char *mesg, VALUE addr, VALUE rai | ) |

## ◆ NORETURN() [11/11]

NORETURN | ( | void | rsock_syserr_fail_sockaddrint err, const char *mesg, struct sockaddr *addr, socklen_t len | ) |

## ◆ rb_check_sockaddr_string_type()

VALUE rb_check_sockaddr_string_type | ( | VALUE |  | ) |

Definition at line 2628 of file raddrinfo.c.

References IS_ADDRINFO.

## ◆ rb_freeaddrinfo()

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

Definition at line 396 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 309 of file raddrinfo.c.

## ◆ 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 437 of file raddrinfo.c.

References arg, getnameinfo_arg::flags, getnameinfo(), getnameinfo_arg::host, getnameinfo_arg::hostlen, int, rb_thread_call_without_gvl(), 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 653 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 1641 of file raddrinfo.c.

Referenced by 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 910 of file raddrinfo.c.

Referenced by 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 arg, argc, argv, BLOCKING_REGION_FD, rb_io_t::fd, rsock_send_arg::flags, GetOpenFile, n, 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(), and rsock_send_arg::to.

## ◆ rsock_cmsg_type_arg()

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

Definition at line 99 of file constants.c.

References IS_IP_FAMILY.

## ◆ rsock_connect()

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

Definition at line 608 of file init.c.

## ◆ rsock_detect_cloexec()

int rsock_detect_cloexec | ( | int | fd | ) |

Definition at line 413 of file init.c.

References errno, F_GETFD, fcntl(), recvfrom_arg::fd, FD_CLOEXEC, recvfrom_arg::flags, rb_bug(), and strerror().

## ◆ rsock_family_arg()

int rsock_family_arg | ( | VALUE | domain | ) |

Definition at line 42 of file constants.c.

## ◆ rsock_fd_family()

int rsock_fd_family | ( | int | fd | ) |

Definition at line 640 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 2636 of file raddrinfo.c.

Referenced by rsock_io_socket_addrinfo().

## ◆ rsock_freeaddrinfo()

VALUE rsock_freeaddrinfo | ( | VALUE | arg | ) |

Definition at line 808 of file raddrinfo.c.

References arg, Qnil, and rb_freeaddrinfo().

## ◆ rsock_getaddrinfo()

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

Definition at line 576 of file raddrinfo.c.

References error, NI_MAXHOST, NI_MAXSERV, and NULL.

Referenced by rsock_addrinfo().

## ◆ rsock_getfamily()

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

Definition at line 787 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 2681 of file raddrinfo.c.

Referenced by rsock_init_socket_init().

## ◆ rsock_init_ancdata()

void rsock_init_ancdata | ( | void |  | ) |

Definition at line 1697 of file ancdata.c.

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

Referenced by rsock_init_socket_init().

## ◆ rsock_init_basicsocket()

void rsock_init_basicsocket | ( | void |  | ) |

Definition at line 704 of file basicsocket.c.

References rb_cBasicSocket, rb_cIO, rb_define_class(), rb_define_singleton_method(), and rb_undef_method().

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
| ) |  |

Definition at line 159 of file ipsocket.c.

References arg, rb_ensure(), and inetsock_arg::sock.

## ◆ rsock_init_ipsocket()

void rsock_init_ipsocket | ( | void |  | ) |

Definition at line 371 of file ipsocket.c.

References rb_cBasicSocket, rb_cIPSocket, rb_define_class(), and rb_define_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 EBADF, 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.

## ◆ 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 819 of file init.c.

References rb_define_class(), rb_eSocket, rb_eStandardError, 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_cData, rb_cSocket, rb_define_class_under(), rb_define_method(), rb_define_singleton_method(), 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(), and rb_define_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(), and rb_define_method().

Referenced by rsock_init_socket_init().

## ◆ rsock_init_tcpsocket()

void rsock_init_tcpsocket | ( | void |  | ) |

Definition at line 68 of file tcpsocket.c.

References rb_cIPSocket, rb_cTCPSocket, rb_define_class(), 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(), and rb_define_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 576 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 1266 of file raddrinfo.c.

References union_sockaddr::addr, AF_UNSPEC, buf, error, getnameinfo(), i, IFNAMSIZ, 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 2655 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.

## ◆ rsock_ipaddr()

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

Definition at line 665 of file raddrinfo.c.

References atoi(), 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(), rsock_raise_socket_error(), and sprintf().

## ◆ rsock_level_arg()

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

Definition at line 56 of file constants.c.

References IS_IP_FAMILY.

## ◆ rsock_make_fd_nonblock()

void rsock_make_fd_nonblock | ( | int | fd | ) |

Definition at line 639 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 816 of file raddrinfo.c.

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

## ◆ rsock_make_ipaddr()

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

Definition at line 470 of file raddrinfo.c.

## ◆ rsock_optname_arg()

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

Definition at line 68 of file constants.c.

References IS_IP_FAMILY.

## ◆ rsock_read_nonblock()

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

## ◆ rsock_revlookup_flag()

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

Definition at line 179 of file ipsocket.c.

References Check_Type, id, Qfalse, Qnil, Qtrue, 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 752 of file init.c.

References arg, BLOCKING_REGION_FD, accept_arg::fd, int, len, 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 710 of file init.c.

References rb_io_set_nonblock().

## ◆ rsock_s_recvfrom()

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

Definition at line 168 of file init.c.

References arg, argc, argv, len, NUM2INT, Qnil, rb_scan_args, and 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 230 of file init.c.

References recvfrom_arg::alen, buf, recvfrom_arg::fd, recvfrom_arg::flags, len, NUM2INT, Qnil, and str.

## ◆ rsock_send_blocking()

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

Definition at line 111 of file init.c.

References arg, do_write_retry, 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 arg, do_write_retry, rsock_send_arg::mesg, RSTRING_LEN, and RSTRING_PTR.

Referenced by rsock_bsock_send().

## ◆ rsock_shutdown_how_arg()

int rsock_shutdown_how_arg | ( | VALUE | how | ) |

Definition at line 130 of file constants.c.

## ◆ rsock_sock_listen()

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

Definition at line 653 of file socket.c.

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

Referenced by 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 * |  | ) |

Definition at line 2597 of file raddrinfo.c.

References IS_ADDRINFO, and v.

Referenced by rsock_sockaddr_string_value_ptr().

## ◆ rsock_sockaddr_string_value_ptr()

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

Definition at line 2621 of file raddrinfo.c.

References rsock_sockaddr_string_value(), RSTRING_PTR, and v.

## ◆ rsock_sockaddr_string_value_with_addrinfo()

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

Definition at line 2608 of file raddrinfo.c.

References IS_ADDRINFO, Qnil, and v.

## ◆ rsock_socket()

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

Definition at line 492 of file init.c.

References recvfrom_arg::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 NEWOBJ_OF, obj, rb_cSockOpt, StringValue(), and T_OBJECT.

## ◆ rsock_socktype_arg()

int rsock_socktype_arg | ( | VALUE | type | ) |

Definition at line 49 of file constants.c.

## ◆ rsock_write_nonblock()

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

## Variable Documentation

## ◆ rb_cAddrinfo

VALUE rb_cAddrinfo

Definition at line 27 of file init.c.

## ◆ rb_cBasicSocket

VALUE rb_cBasicSocket

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

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

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

Definition at line 3 of file option.c.

Referenced by rsock_init_sockopt(), and rsock_sockopt_new().

## ◆ rb_cTCPServer

VALUE rb_cTCPServer

Definition at line 20 of file init.c.

Referenced by rsock_init_tcpserver().

## ◆ rb_cTCPSocket

VALUE rb_cTCPSocket

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

Definition at line 21 of file init.c.

Referenced by rsock_init_udpsocket().

## ◆ rb_eSocket

VALUE rb_eSocket

Definition at line 29 of file init.c.

Referenced by rsock_init_socket_init().

## ◆ rsock_cmsg_cloexec_state

int rsock_cmsg_cloexec_state

Definition at line 5 of file ancdata.c.

## ◆ rsock_do_not_reverse_lookup

int rsock_do_not_reverse_lookup

Definition at line 35 of file init.c.

Referenced by rsock_init_sock().

_SS_PAD1SIZE
#define _SS_PAD1SIZE
Definition: rubysocket.h:175
CHAR_BIT
#define CHAR_BIT
Definition: ruby.h:227
socklen_t
int socklen_t
Definition: getaddrinfo.c:83
_SS_ALIGNSIZE
#define _SS_ALIGNSIZE
Definition: rubysocket.h:174
char
#define char
Definition: rb_mjit_min_header-2.7.0.h:2876
socklen_t
int socklen_t
Definition: rubysocket.h:114
_SS_MAXSIZE
#define _SS_MAXSIZE
Definition: rubysocket.h:173