Ruby
2.4.2p198(2017-09-14revision59899)
|
#include "rubysocket.h"
Go to the source code of this file.
Data Structures | |
struct | recvfrom_arg |
struct | connect_arg |
struct | accept_arg |
Functions | |
void | rsock_raise_socket_error (const char *reason, int error) |
static int | is_socket (int fd) |
VALUE | rsock_init_sock (VALUE sock, int fd) |
VALUE | rsock_sendto_blocking (void *data) |
VALUE | rsock_send_blocking (void *data) |
static VALUE | recvfrom_blocking (void *data) |
static VALUE | rsock_strbuf (VALUE str, long buflen) |
static VALUE | recvfrom_locktmp (VALUE v) |
VALUE | rsock_s_recvfrom (VALUE sock, int argc, VALUE *argv, enum sock_recv_type from) |
VALUE | rsock_s_recvfrom_nonblock (VALUE sock, VALUE len, VALUE flg, VALUE str, VALUE ex, enum sock_recv_type from) |
int | rsock_detect_cloexec (int fd) |
static int | rsock_socket0 (int domain, int type, int proto) |
int | rsock_socket (int domain, int type, int proto) |
static int | wait_connectable (int fd) |
static VALUE | connect_blocking (void *data) |
int | rsock_connect (int fd, const struct sockaddr *sockaddr, int len, int socks) |
static void | make_fd_nonblock (int fd) |
static int | cloexec_accept (int socket, struct sockaddr *address, socklen_t *address_len, int nonblock) |
VALUE | rsock_s_accept_nonblock (VALUE klass, VALUE ex, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len) |
static VALUE | accept_blocking (void *data) |
VALUE | rsock_s_accept (VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len) |
int | rsock_getfamily (rb_io_t *fptr) |
void | rsock_init_socket_init (void) |
|
static |
Definition at line 588 of file init.c.
References cloexec_accept(), accept_arg::fd, accept_arg::len, and accept_arg::sockaddr.
Referenced by rsock_s_accept().
|
static |
Definition at line 503 of file init.c.
References errno, recvfrom_arg::flags, make_fd_nonblock(), and rb_maygvl_fd_fix_cloexec().
Referenced by accept_blocking(), and rsock_s_accept_nonblock().
|
static |
Definition at line 438 of file init.c.
References connect_arg::fd, connect_arg::len, and connect_arg::sockaddr.
Referenced by rsock_connect().
|
static |
Definition at line 49 of file init.c.
References fstat, rb_sys_fail(), and stat.
Referenced by rsock_init_sock().
|
static |
Definition at line 485 of file init.c.
References F_SETFL, fcntl(), recvfrom_arg::flags, O_NONBLOCK, and rb_sys_fail().
Referenced by cloexec_accept().
|
static |
Definition at line 107 of file init.c.
References union_sockaddr::addr, recvfrom_arg::alen, recvfrom_arg::buf, recvfrom_arg::fd, recvfrom_arg::flags, RSTRING_LEN, RSTRING_PTR, and recvfrom_arg::str.
Referenced by recvfrom_locktmp().
Definition at line 138 of file init.c.
References recvfrom_arg::fd, rb_thread_io_blocking_region(), and recvfrom_blocking().
Referenced by rsock_s_recvfrom().
int rsock_connect | ( | int | fd, |
const struct sockaddr * | sockaddr, | ||
int | len, | ||
int | socks | ||
) |
Definition at line 454 of file init.c.
References BLOCKING_REGION_FD, connect_blocking(), EINPROGRESS, errno, recvfrom_arg::fd, connect_arg::fd, func, len, connect_arg::len, connect_arg::sockaddr, and wait_connectable().
Referenced by init_inetsock_internal(), sock_connect(), and udp_connect_internal().
int rsock_detect_cloexec | ( | int | fd | ) |
Definition at line 284 of file init.c.
References errno, F_GETFD, fcntl(), FD_CLOEXEC, recvfrom_arg::flags, proto, rb_bug(), rb_maygvl_fd_fix_cloexec(), rb_update_max_fd(), rsock_detect_cloexec(), rsock_socket0(), and strerror().
Referenced by rsock_detect_cloexec(), and sock_initialize().
int rsock_getfamily | ( | rb_io_t * | fptr | ) |
Definition at line 630 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.
Referenced by bsock_getsockopt(), and bsock_setsockopt().
Definition at line 60 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 bsock_s_for_fd(), init_inetsock_internal(), rsock_s_accept(), rsock_s_accept_nonblock(), sock_initialize(), and udp_init().
void rsock_init_socket_init | ( | void | ) |
Definition at line 662 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(), rsock_init_unixsocket(), and sym_wait_readable.
Referenced by Init_socket().
void rsock_raise_socket_error | ( | const char * | reason, |
int | error | ||
) |
Definition at line 35 of file init.c.
References EAI_SYSTEM, errno, gai_strerror(), rb_eSocket, rb_raise(), and rb_syserr_fail().
Referenced by addrinfo_getnameinfo(), addrinfo_mdump(), make_ipaddr0(), rsock_getaddrinfo(), rsock_inspect_sockaddr(), rsock_ipaddr(), and sock_s_getnameinfo().
Definition at line 595 of file init.c.
References accept_blocking(), BLOCKING_REGION_FD, errno, recvfrom_arg::fd, accept_arg::fd, 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.
Referenced by sock_accept(), sock_sysaccept(), tcp_accept(), and tcp_sysaccept().
VALUE rsock_s_accept_nonblock | ( | VALUE | klass, |
VALUE | ex, | ||
rb_io_t * | fptr, | ||
struct sockaddr * | sockaddr, | ||
socklen_t * | len | ||
) |
Definition at line 553 of file init.c.
References cloexec_accept(), ECONNABORTED, errno, EWOULDBLOCK, rb_io_t::fd, 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 sym_wait_readable.
Referenced by sock_accept_nonblock(), and tcp_accept_nonblock().
VALUE rsock_s_recvfrom | ( | VALUE | sock, |
int | argc, | ||
VALUE * | argv, | ||
enum sock_recv_type | from | ||
) |
Definition at line 146 of file init.c.
References union_sockaddr::addr, recvfrom_arg::alen, recvfrom_arg::buf, rb_io_t::fd, recvfrom_arg::fd, recvfrom_arg::flags, FMODE_NOREVLOOKUP, GetOpenFile, len, 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_obj_taint(), rb_raise(), rb_scan_args(), rb_str_locktmp_ensure(), rb_str_set_len(), rb_sys_fail(), RECV_IP, RECV_RECV, RECV_SOCKET, RECV_UNIX, recvfrom_locktmp(), rsock_io_socket_addrinfo(), rsock_ipaddr(), rsock_maybe_wait_fd, rsock_strbuf(), RSTRING_LEN, and recvfrom_arg::str.
Referenced by bsock_recv(), ip_recvfrom(), and sock_recvfrom().
VALUE rsock_s_recvfrom_nonblock | ( | VALUE | sock, |
VALUE | len, | ||
VALUE | flg, | ||
VALUE | str, | ||
VALUE | ex, | ||
enum sock_recv_type | from | ||
) |
Definition at line 209 of file init.c.
References union_sockaddr::addr, recvfrom_arg::alen, recvfrom_arg::buf, errno, EWOULDBLOCK, rb_io_t::fd, recvfrom_arg::fd, recvfrom_arg::flags, FMODE_NOREVLOOKUP, GetOpenFile, 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_obj_taint(), 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(), rsock_strbuf(), RSTRING_LEN, RSTRING_PTR, recvfrom_arg::str, and sym_wait_readable.
Referenced by bsock_recv_nonblock(), sock_recvfrom_nonblock(), and udp_recvfrom_nonblock().
VALUE rsock_send_blocking | ( | void * | data | ) |
Definition at line 91 of file init.c.
References rsock_send_arg::fd, rsock_send_arg::flags, rsock_send_arg::mesg, RSTRING_LEN, and RSTRING_PTR.
Referenced by rsock_bsock_send().
VALUE rsock_sendto_blocking | ( | void * | data | ) |
Definition at line 82 of file init.c.
References 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(), and udp_send_internal().
int rsock_socket | ( | int | domain, |
int | type, | ||
int | proto | ||
) |
Definition at line 357 of file init.c.
References errno, recvfrom_arg::fd, rb_gc_for_fd(), rb_update_max_fd(), and rsock_socket0().
Referenced by init_inetsock_internal(), sock_initialize(), and udp_init().
|
static |
Definition at line 344 of file init.c.
References rb_fd_fix_cloexec().
Referenced by rsock_detect_cloexec(), and rsock_socket().
Definition at line 120 of file init.c.
References len, NIL_P, rb_str_modify(), rb_str_modify_expand(), rb_str_set_len(), rb_tainted_str_new(), RSTRING_LEN, recvfrom_arg::str, and StringValue.
Referenced by rsock_s_recvfrom(), and rsock_s_recvfrom_nonblock().
|
static |
Definition at line 374 of file init.c.
References EALREADY, EINPROGRESS, EISCONN, errno, NULL, rb_wait_for_single_fd(), RB_WAITFD_IN, and RB_WAITFD_OUT.
Referenced by rsock_connect().
VALUE rb_cAddrinfo |
Definition at line 23 of file init.c.
Referenced by addrinfo_s_udp(), rsock_addrinfo_new(), and rsock_init_addrinfo().
VALUE rb_cBasicSocket |
Definition at line 13 of file init.c.
Referenced by Init_socket(), rsock_init_basicsocket(), rsock_init_ipsocket(), and rsock_init_unixsocket().
VALUE rb_cIPSocket |
Definition at line 14 of file init.c.
Referenced by rsock_init_ipsocket(), rsock_init_tcpsocket(), and rsock_init_udpsocket().
VALUE rb_cSocket |
Definition at line 22 of file init.c.
Referenced by init_constants(), Init_socket(), rsock_init_ancdata(), rsock_init_sockifaddr(), rsock_init_sockopt(), sock_accept(), and sock_accept_nonblock().
VALUE rb_cTCPServer |
Definition at line 16 of file init.c.
Referenced by rsock_init_tcpserver().
VALUE rb_cTCPSocket |
Definition at line 15 of file init.c.
Referenced by rsock_init_sockssocket(), rsock_init_tcpserver(), rsock_init_tcpsocket(), tcp_accept(), and tcp_accept_nonblock().
VALUE rb_cUDPSocket |
Definition at line 17 of file init.c.
Referenced by rsock_init_udpsocket().
VALUE rb_eSocket |
Definition at line 25 of file init.c.
Referenced by addrinfo_initialize(), addrinfo_ip_address(), addrinfo_ip_port(), addrinfo_ip_unpack(), addrinfo_ipv4_multicast_p(), addrinfo_mdump(), addrinfo_mload(), call_getaddrinfo(), constant_arg(), make_addrinfo(), rsock_getaddrinfo(), rsock_init_socket_init(), rsock_raise_socket_error(), sock_s_gethostbyaddr(), sock_s_getnameinfo(), sock_s_getservbyname(), sock_s_getservbyport(), and sock_sockaddr().
int rsock_do_not_reverse_lookup = 1 |
Definition at line 31 of file init.c.
Referenced by bsock_do_not_rev_lookup(), bsock_do_not_rev_lookup_set(), rsock_init_sock(), and sock_s_getaddrinfo().
|
static |
Definition at line 32 of file init.c.
Referenced by rsock_init_socket_init(), rsock_s_accept_nonblock(), and rsock_s_recvfrom_nonblock().