Ruby 2.1.5p273(2014-11-13revision48405)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

rubysocket.h
Go to the documentation of this file.
1 #ifndef RUBY_SOCKET_H
2 #define RUBY_SOCKET_H 1
3
4 #include "ruby/ruby.h"
5 #include "ruby/io.h"
6 #include "ruby/thread.h"
7 #include "ruby/util.h"
8 #include "internal.h"
9 #include <stdio.h>
10 #include <sys/types.h>
11 #include <sys/stat.h>
12
13 #ifdef HAVE_UNISTD_H
14 # include <unistd.h>
15 #endif
16
17 #ifdef HAVE_SYS_UIO_H
18 # include <sys/uio.h>
19 #endif
20
21 #ifdef HAVE_XTI_H
22 # include <xti.h>
23 #endif
24
25 #ifdef _WIN32
26 # if defined(_MSC_VER)
27 # undef HAVE_TYPE_STRUCT_SOCKADDR_DL
28 # endif
29 #else
30 # if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
31 # include <net/socket.h>
32 # else
33 # include <sys/socket.h>
34 # endif
35 # include <netinet/in.h>
36 # ifdef HAVE_NETINET_IN_SYSTM_H
37 # include <netinet/in_systm.h>
38 # endif
39 # ifdef HAVE_NETINET_TCP_H
40 # include <netinet/tcp.h>
41 # endif
42 # ifdef HAVE_NETINET_UDP_H
43 # include <netinet/udp.h>
44 # endif
45 # ifdef HAVE_ARPA_INET_H
46 # include <arpa/inet.h>
47 # endif
48 # include <netdb.h>
49 #endif
50
51 #ifdef HAVE_NETPACKET_PACKET_H
52 # include <netpacket/packet.h>
53 #endif
54 #ifdef HAVE_NET_ETHERNET_H
55 # include <net/ethernet.h>
56 #endif
57
58 #include <errno.h>
59
60 #ifdef HAVE_SYS_UN_H
61 # include <sys/un.h>
62 #endif
63
64 #if defined(HAVE_FCNTL)
65 # ifdef HAVE_SYS_SELECT_H
66 # include <sys/select.h>
67 # endif
68 # ifdef HAVE_SYS_TYPES_H
69 # include <sys/types.h>
70 # endif
71 # ifdef HAVE_SYS_TIME_H
72 # include <sys/time.h>
73 # endif
74 # ifdef HAVE_FCNTL_H
75 # include <fcntl.h>
76 # endif
77 #endif
78
79 #ifdef HAVE_IFADDRS_H
80 # include <ifaddrs.h>
81 #endif
82 #ifdef HAVE_SYS_IOCTL_H
83 # include <sys/ioctl.h>
84 #endif
85 #ifdef HAVE_SYS_SOCKIO_H
86 # include <sys/sockio.h>
87 #endif
88 #ifdef HAVE_NET_IF_H
89 # include <net/if.h>
90 #endif
91
92 #ifdef HAVE_SYS_PARAM_H
93 # include <sys/param.h>
94 #endif
95 #ifdef HAVE_SYS_UCRED_H
96 # include <sys/ucred.h>
97 #endif
98 #ifdef HAVE_UCRED_H
99 # include <ucred.h>
100 #endif
101 #ifdef HAVE_NET_IF_DL_H
102 # include <net/if_dl.h>
103 #endif
104
105 #ifndef HAVE_TYPE_SOCKLEN_T
106 typedef int socklen_t;
107 #endif
108
109 #ifdef NEED_IF_INDEXTONAME_DECL
110 char *if_indextoname(unsigned int, char *);
111 #endif
112 #ifdef NEED_IF_NAMETOINDEX_DECL
113 unsigned int if_nametoindex(const char *);
114 #endif
115
116 #define SOCKLEN_MAX \
117 (0 < (socklen_t)-1 ? \
118 ~(socklen_t)0 : \
119 (((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
120
121 #ifndef RSTRING_SOCKLEN
122 # define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
123 #endif
124
125 #ifndef EWOULDBLOCK
126 # define EWOULDBLOCK EAGAIN
127 #endif
128
129 /*
130 * workaround for NetBSD, OpenBSD and etc.
131 * The problem is since 4.4BSD-Lite.
132 * FreeBSD fix the problem at FreeBSD 2.2.0.
133 * NetBSD fix the problem at NetBSD 3.0 by kern/29624.
134 * OpenBSD fix the problem at OpenBSD 3.8.
135 */
136 #define pseudo_AF_FTIP pseudo_AF_RTIP
137
138 #ifndef HAVE_GETADDRINFO
139 # include "addrinfo.h"
140 #endif
141
142 #include "sockport.h"
143
144 #ifndef NI_MAXHOST
145 # define NI_MAXHOST 1025
146 #endif
147 #ifndef NI_MAXSERV
148 # define NI_MAXSERV 32
149 #endif
150
151 #ifdef AF_INET6
152 # define IS_IP_FAMILY(af) ((af) == AF_INET || (af) == AF_INET6)
153 #else
154 # define IS_IP_FAMILY(af) ((af) == AF_INET)
155 #endif
156
157 #ifndef IN6_IS_ADDR_UNIQUE_LOCAL
158 # define IN6_IS_ADDR_UNIQUE_LOCAL(a) (((a)->s6_addr[0] == 0xfc) || ((a)->s6_addr[0] == 0xfd))
159 #endif
160
161 #ifndef HAVE_TYPE_STRUCT_SOCKADDR_STORAGE
162 /*
163 * RFC 2553: protocol-independent placeholder for socket addresses
164 */
165 # define _SS_MAXSIZE 128
166 # define _SS_ALIGNSIZE (sizeof(double))
167 # define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
168 # define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
169 _SS_PAD1SIZE - _SS_ALIGNSIZE)
170
171 struct sockaddr_storage {
172 # ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
173 unsigned char ss_len; /* address length */
174 unsigned char ss_family; /* address family */
175 # else
176 unsigned short ss_family;
177 # endif
178 char __ss_pad1[_SS_PAD1SIZE];
179 double __ss_align; /* force desired structure storage alignment */
180 char __ss_pad2[_SS_PAD2SIZE];
181 };
182 #endif
183
184 typedef union {
185 struct sockaddr addr;
186 struct sockaddr_in in;
187 #ifdef AF_INET6
188 struct sockaddr_in6 in6;
189 #endif
190 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_UN
191 struct sockaddr_un un;
192 #endif
193 #ifdef HAVE_TYPE_STRUCT_SOCKADDR_DL
194 struct sockaddr_dl dl; /* AF_LINK */
195 #endif
196 struct sockaddr_storage storage;
197 char place_holder[2048]; /* sockaddr_storage is not enough for Unix domain sockets on SunOS and Darwin. */
198 } union_sockaddr;
199
200 #ifdef __APPLE__
201 /*
202 * CMSG_ macros are broken on 64bit darwin, because __DARWIN_ALIGN
203 * aligns up to __darwin_size_t which is 64bit, but CMSG_DATA is
204 * 32bit-aligned.
205 */
206 # undef __DARWIN_ALIGNBYTES
207 # define __DARWIN_ALIGNBYTES (sizeof(unsigned int) - 1)
208 #endif
209
210 #if defined(_AIX)
211 # ifndef CMSG_SPACE
212 # define CMSG_SPACE(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + _CMSG_ALIGN(len))
213 # endif
214 # ifndef CMSG_LEN
215 # define CMSG_LEN(len) (_CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
216 # endif
217 #endif
218
219 #ifdef __BEOS__
220 # undef close
221 # define close closesocket
222 #endif
223
224 #define INET_CLIENT 0
225 #define INET_SERVER 1
226 #define INET_SOCKS 2
227
228 extern int rsock_do_not_reverse_lookup;
229 #define FMODE_NOREVLOOKUP 0x100
230
231 extern VALUE rb_cBasicSocket;
232 extern VALUE rb_cIPSocket;
233 extern VALUE rb_cTCPSocket;
234 extern VALUE rb_cTCPServer;
235 extern VALUE rb_cUDPSocket;
236 #ifdef HAVE_SYS_UN_H
237 extern VALUE rb_cUNIXSocket;
238 extern VALUE rb_cUNIXServer;
239 #endif
240 extern VALUE rb_cSocket;
241 extern VALUE rb_cAddrinfo;
242 extern VALUE rb_cSockOpt;
243
244 extern VALUE rb_eSocket;
245
246 #ifdef SOCKS
247 extern VALUE rb_cSOCKSSocket;
248 # ifdef SOCKS5
249 # include <socks.h>
250 # else
251 void SOCKSinit();
252 int Rconnect();
253 # endif
254 #endif
255
256 #include "constdefs.h"
257
258 #define BLOCKING_REGION(func, arg) (long)rb_thread_blocking_region((func), (arg), RUBY_UBF_IO, 0)
259 #define BLOCKING_REGION_FD(func, arg) (long)rb_thread_io_blocking_region((func), (arg), (arg)->fd)
260
261 #define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
262 #define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
263 #define SockAddrStringValueWithAddrinfo(v, rai_ret) rsock_sockaddr_string_value_with_addrinfo(&(v), &(rai_ret))
264 VALUE rsock_sockaddr_string_value(volatile VALUE *);
265 char *rsock_sockaddr_string_value_ptr(volatile VALUE *);
266 VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret);
267
268 VALUE rb_check_sockaddr_string_type(VALUE);
269
270 NORETURN(void rsock_raise_socket_error(const char *, int));
271
272 int rsock_family_arg(VALUE domain);
273 int rsock_socktype_arg(VALUE type);
274 int rsock_level_arg(int family, VALUE level);
275 int rsock_optname_arg(int family, int level, VALUE optname);
276 int rsock_cmsg_type_arg(int family, int level, VALUE type);
277 int rsock_shutdown_how_arg(VALUE how);
278
279 int rsock_getfamily(int sockfd);
280
281 struct rb_addrinfo {
282 struct addrinfo *ai;
283 int allocated_by_malloc;
284 };
285 int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res);
286 void rb_freeaddrinfo(struct rb_addrinfo *ai);
287 VALUE rsock_freeaddrinfo(VALUE arg);
288 int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
289 struct rb_addrinfo *rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags);
290 struct rb_addrinfo *rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
291 VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
292 VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
293
294 VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
295 VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai);
296
297 VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen);
298 VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup);
299 VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, socklen_t));
300 VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret);
301 socklen_t rsock_sockaddr_len(struct sockaddr *addr);
302 VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len);
303
304 int rsock_revlookup_flag(VALUE revlookup, int *norevlookup);
305
306 #ifdef HAVE_SYS_UN_H
307 VALUE rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len);
308 VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
309 socklen_t rsock_unix_sockaddr_len(VALUE path);
310 #endif
311
312 int rsock_socket(int domain, int type, int proto);
313 VALUE rsock_init_sock(VALUE sock, int fd);
314 VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass);
315 VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type);
316 VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server);
317
318 struct rsock_send_arg {
319 int fd, flags;
320 VALUE mesg;
321 struct sockaddr *to;
322 socklen_t tolen;
323 };
324
325 VALUE rsock_sendto_blocking(void *data);
326 VALUE rsock_send_blocking(void *data);
327 VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock);
328
329 enum sock_recv_type {
330 RECV_RECV, /* BasicSocket#recv(no from) */
331 RECV_IP, /* IPSocket#recvfrom */
332 RECV_UNIX, /* UNIXSocket#recvfrom */
333 RECV_SOCKET /* Socket#recvfrom */
334 };
335
336 VALUE rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
337 VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
338
339 int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
340
341 VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
342 VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len);
343 VALUE rsock_sock_listen(VALUE sock, VALUE log);
344
345 VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
346
347 #if defined(HAVE_SENDMSG)
348 VALUE rsock_bsock_sendmsg(int argc, VALUE *argv, VALUE sock);
349 VALUE rsock_bsock_sendmsg_nonblock(int argc, VALUE *argv, VALUE sock);
350 #else
351 #define rsock_bsock_sendmsg rb_f_notimplement
352 #define rsock_bsock_sendmsg_nonblock rb_f_notimplement
353 #endif
354
355 #if defined(HAVE_RECVMSG)
356 VALUE rsock_bsock_recvmsg(int argc, VALUE *argv, VALUE sock);
357 VALUE rsock_bsock_recvmsg_nonblock(int argc, VALUE *argv, VALUE sock);
358 ssize_t rsock_recvmsg(int socket, struct msghdr *message, int flags);
359 #else
360 #define rsock_bsock_recvmsg rb_f_notimplement
361 #define rsock_bsock_recvmsg_nonblock rb_f_notimplement
362 #endif
363
364 #ifdef HAVE_STRUCT_MSGHDR_MSG_CONTROL
365 void rsock_discard_cmsg_resource(struct msghdr *mh, int msg_peek_p);
366 #endif
367
368 void rsock_init_basicsocket(void);
369 void rsock_init_ipsocket(void);
370 void rsock_init_tcpsocket(void);
371 void rsock_init_tcpserver(void);
372 void rsock_init_sockssocket(void);
373 void rsock_init_udpsocket(void);
374 void rsock_init_unixsocket(void);
375 void rsock_init_unixserver(void);
376 void rsock_init_socket_constants(void);
377 void rsock_init_ancdata(void);
378 void rsock_init_addrinfo(void);
379 void rsock_init_sockopt(void);
380 void rsock_init_sockifaddr(void);
381 void rsock_init_socket_init(void);
382
383 NORETURN(void rsock_syserr_fail_host_port(int err, const char *, VALUE, VALUE));
384 NORETURN(void rsock_syserr_fail_path(int err, const char *, VALUE));
385 NORETURN(void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len));
386 NORETURN(void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai));
387 NORETURN(void rsock_syserr_fail_raddrinfo_or_sockaddr(int err, const char *mesg, VALUE addr, VALUE rai));
388
389 NORETURN(void rsock_sys_fail_host_port(const char *, VALUE, VALUE));
390 NORETURN(void rsock_sys_fail_path(const char *, VALUE));
391 NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, socklen_t len));
392 NORETURN(void rsock_sys_fail_raddrinfo(const char *, VALUE rai));
393 NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VALUE rai));
394
395 #endif
rsock_optname_arg
int rsock_optname_arg(int family, int level, VALUE optname)
Definition: constants.c:69
rsock_init_unixsock
VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server)
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:102
rsock_init_inetsock
VALUE rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type)
Definition: ipsocket.c:145
rsock_addrinfo_inspect_sockaddr
VALUE rsock_addrinfo_inspect_sockaddr(VALUE rai)
Definition: raddrinfo.c:1465
rsock_init_sockifaddr
void rsock_init_sockifaddr(void)
Definition: ifaddr.c:437
rsock_ipaddr
VALUE rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
Definition: raddrinfo.c:505
rsock_send_arg::tolen
socklen_t tolen
Definition: rubysocket.h:322
addrinfo.h
rsock_shutdown_how_arg
int rsock_shutdown_how_arg(VALUE how)
Definition: constants.c:131
rsock_init_basicsocket
void rsock_init_basicsocket(void)
Definition: basicsocket.c:739
rsock_sockaddr_obj
VALUE rsock_sockaddr_obj(struct sockaddr *addr, socklen_t len)
rsock_do_not_reverse_lookup
int rsock_do_not_reverse_lookup
Definition: init.c:31
ruby.h
rsock_level_arg
int rsock_level_arg(int family, VALUE level)
Definition: constants.c:57
rsock_sock_listen
VALUE rsock_sock_listen(VALUE sock, VALUE log)
Definition: socket.c:659
rsock_bsock_send
VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
Definition: basicsocket.c:542
rb_io_t
Definition: io.h:61
msghdr
Definition: win32.h:235
rb_cSockOpt
VALUE rb_cSockOpt
Definition: option.c:3
sockaddr_storage::__ss_align
double __ss_align
Definition: rubysocket.h:179
rsock_send_blocking
VALUE rsock_send_blocking(void *data)
Definition: init.c:82
rsock_io_socket_addrinfo
VALUE rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2481
rsock_init_unixsocket
void rsock_init_unixsocket(void)
Definition: unixsocket.c:506
rsock_init_socket_init
void rsock_init_socket_init(void)
Definition: init.c:618
RECV_RECV
Definition: rubysocket.h:330
rsock_init_tcpserver
void rsock_init_tcpserver(void)
Definition: tcpserver.c:139
rsock_send_arg::to
struct sockaddr * to
Definition: rubysocket.h:321
sock_recv_type
sock_recv_type
Definition: rubysocket.h:329
rsock_bsock_sendmsg
#define rsock_bsock_sendmsg
Definition: rubysocket.h:351
sockaddr_storage::__ss_pad2
char __ss_pad2[_SS_PAD2SIZE]
Definition: rubysocket.h:180
rb_cTCPServer
VALUE rb_cTCPServer
Definition: init.c:16
rsock_send_arg::mesg
VALUE mesg
Definition: rubysocket.h:320
rb_cUDPSocket
VALUE rb_cUDPSocket
Definition: init.c:17
rsock_send_arg::fd
int fd
Definition: rubysocket.h:319
rb_cIPSocket
VALUE rb_cIPSocket
Definition: init.c:14
rsock_syserr_fail_raddrinfo
void rsock_syserr_fail_raddrinfo(int err, const char *mesg, VALUE rai)
Definition: socket.c:85
rsock_make_ipaddr
VALUE rsock_make_ipaddr(struct sockaddr *addr, socklen_t addrlen)
Definition: raddrinfo.c:367
socklen_t
int socklen_t
Definition: rubysocket.h:106
io.h
rsock_sockaddr_len
socklen_t rsock_sockaddr_len(struct sockaddr *addr)
rsock_init_socket_constants
void rsock_init_socket_constants(void)
Definition: constants.c:141
rsock_syserr_fail_host_port
void rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
Definition: socket.c:22
rb_addrinfo
Definition: rubysocket.h:281
rsock_sockaddr_string_value
VALUE rsock_sockaddr_string_value(volatile VALUE *)
Definition: raddrinfo.c:2423
thread.h
rsock_make_hostent
VALUE rsock_make_hostent(VALUE host, struct rb_addrinfo *addr, VALUE(*ipaddr)(struct sockaddr *, socklen_t))
Definition: raddrinfo.c:649
rsock_sock_s_socketpair
VALUE rsock_sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
rsock_send_arg
Definition: rubysocket.h:318
rsock_init_tcpsocket
void rsock_init_tcpsocket(void)
Definition: tcpsocket.c:59
level
#define level
rsock_bsock_sendmsg_nonblock
#define rsock_bsock_sendmsg_nonblock
Definition: rubysocket.h:352
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:746
rsock_init_sockssocket
void rsock_init_sockssocket(void)
Definition: sockssocket.c:55
union_sockaddr
Definition: rubysocket.h:184
rsock_syserr_fail_path
void rsock_syserr_fail_path(int err, const char *mesg, VALUE path)
Definition: socket.c:41
rsock_init_sockopt
void rsock_init_sockopt(void)
Definition: option.c:1087
unistd.h
_SS_PAD2SIZE
#define _SS_PAD2SIZE
Definition: rubysocket.h:168
rsock_sockaddr_string_value_with_addrinfo
VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret)
Definition: raddrinfo.c:2434
argc
int argc
Definition: ruby.c:131
rb_eSocket
VALUE rb_eSocket
Definition: init.c:25
rsock_bsock_recvmsg_nonblock
#define rsock_bsock_recvmsg_nonblock
Definition: rubysocket.h:361
err
int err
Definition: win32.c:114
rsock_s_recvfrom
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
Definition: init.c:111
sockaddr_storage::ss_family
unsigned short ss_family
Definition: rubysocket.h:176
sockport.h
rb_check_sockaddr_string_type
VALUE rb_check_sockaddr_string_type(VALUE)
Definition: raddrinfo.c:2454
rsock_sockopt_new
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data)
Definition: option.c:62
NORETURN
NORETURN(void rsock_raise_socket_error(const char *, int))
util.h
socklen_t
int socklen_t
Definition: getaddrinfo.c:84
rsock_syserr_fail_sockaddr
void rsock_syserr_fail_sockaddr(int err, const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:69
rb_cSocket
VALUE rb_cSocket
Definition: init.c:22
rsock_init_sock
VALUE rsock_init_sock(VALUE sock, int fd)
Definition: init.c:43
internal.h
rsock_init_udpsocket
void rsock_init_udpsocket(void)
Definition: udpsocket.c:251
sockaddr_storage
Definition: rubysocket.h:171
rsock_sys_fail_sockaddr
void rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
Definition: socket.c:63
type
int type
Definition: tcltklib.c:112
rsock_sys_fail_host_port
void rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
Definition: socket.c:16
VALUE
unsigned long VALUE
Definition: ruby.h:88
rsock_init_ipsocket
void rsock_init_ipsocket(void)
Definition: ipsocket.c:318
rsock_socket
int rsock_socket(int domain, int type, int proto)
Definition: init.c:285
rsock_revlookup_flag
int rsock_revlookup_flag(VALUE revlookup, int *norevlookup)
Definition: ipsocket.c:165
rsock_connect
int rsock_connect(int fd, const struct sockaddr *sockaddr, int len, int socks)
Definition: init.c:386
rsock_getaddrinfo
struct rb_addrinfo * rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack)
Definition: raddrinfo.c:465
rsock_freeaddrinfo
VALUE rsock_freeaddrinfo(VALUE arg)
Definition: raddrinfo.c:641
rsock_sys_fail_raddrinfo
void rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
Definition: socket.c:79
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:334
rsock_addrinfo
struct rb_addrinfo * rsock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
Definition: raddrinfo.c:493
rsock_s_recvfrom_nonblock
VALUE rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
Definition: init.c:179
rsock_socktype_arg
int rsock_socktype_arg(VALUE type)
Definition: constants.c:50
constdefs.h
rsock_getfamily
int rsock_getfamily(int sockfd)
Definition: init.c:605
RECV_IP
Definition: rubysocket.h:331
rsock_sys_fail_raddrinfo_or_sockaddr
void rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
Definition: socket.c:96
proto
#define proto(p)
Definition: sdbm.h:60
rb_cBasicSocket
VALUE rb_cBasicSocket
Definition: init.c:13
rsock_raise_socket_error
void rsock_raise_socket_error(const char *reason, int error)
Definition: init.c:34
rb_addrinfo::ai
struct addrinfo * ai
Definition: rubysocket.h:282
rsock_init_ancdata
void rsock_init_ancdata(void)
Definition: ancdata.c:1796
RECV_UNIX
Definition: rubysocket.h:332
sockaddr_storage::__ss_pad1
char __ss_pad1[_SS_PAD1SIZE]
Definition: rubysocket.h:178
rsock_inspect_sockaddr
VALUE rsock_inspect_sockaddr(struct sockaddr *addr, socklen_t socklen, VALUE ret)
Definition: raddrinfo.c:1089
_SS_PAD1SIZE
#define _SS_PAD1SIZE
Definition: rubysocket.h:167
rsock_send_arg::flags
int flags
Definition: rubysocket.h:319
rsock_s_accept
VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:571
rsock_init_unixserver
void rsock_init_unixserver(void)
Definition: unixserver.c:139
rsock_s_accept_nonblock
VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
Definition: init.c:531
RECV_SOCKET
Definition: rubysocket.h:333
rsock_family_arg
int rsock_family_arg(VALUE domain)
Definition: constants.c:43
rsock_sys_fail_path
void rsock_sys_fail_path(const char *mesg, VALUE path)
Definition: socket.c:35
rsock_sockaddr_string_value_ptr
char * rsock_sockaddr_string_value_ptr(volatile VALUE *)
Definition: raddrinfo.c:2447
rsock_bsock_recvmsg
#define rsock_bsock_recvmsg
Definition: rubysocket.h:360
rb_cAddrinfo
VALUE rb_cAddrinfo
Definition: init.c:23
addrinfo
Definition: addrinfo.h:131
rb_getaddrinfo
int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct rb_addrinfo **res)
Definition: raddrinfo.c:259
rsock_init_addrinfo
void rsock_init_addrinfo(void)
Definition: raddrinfo.c:2507
rb_addrinfo::allocated_by_malloc
int allocated_by_malloc
Definition: rubysocket.h:283
rsock_sendto_blocking
VALUE rsock_sendto_blocking(void *data)
Definition: init.c:73
rb_freeaddrinfo
void rb_freeaddrinfo(struct rb_addrinfo *ai)
Definition: raddrinfo.c:293
rsock_cmsg_type_arg
int rsock_cmsg_type_arg(int family, int level, VALUE type)
Definition: constants.c:100
argv
char ** argv
Definition: ruby.c:132
rsock_fd_socket_addrinfo
VALUE rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
Definition: raddrinfo.c:2462
rb_cTCPSocket
VALUE rb_cTCPSocket
Definition: init.c:15