mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket: add rsock_prefix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
faabbf230a
commit
c49f05dd79
17 changed files with 285 additions and 281 deletions
|
@ -1,3 +1,7 @@
|
|||
Sun Mar 1 15:29:31 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket: add rsock_prefix.
|
||||
|
||||
Sat Feb 28 21:52:37 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* vm_eval.c (rb_iterate): use volatile to suppress warnings.
|
||||
|
|
|
@ -21,17 +21,17 @@ ip_cmsg_type_to_sym(int level, int cmsg_type)
|
|||
{
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_to_sym(cmsg_type, intern_scm_optname);
|
||||
return constant_to_sym(cmsg_type, rsock_intern_scm_optname);
|
||||
case IPPROTO_IP:
|
||||
return constant_to_sym(cmsg_type, intern_ip_optname);
|
||||
return constant_to_sym(cmsg_type, rsock_intern_ip_optname);
|
||||
#ifdef IPPROTO_IPV6
|
||||
case IPPROTO_IPV6:
|
||||
return constant_to_sym(cmsg_type, intern_ipv6_optname);
|
||||
return constant_to_sym(cmsg_type, rsock_intern_ipv6_optname);
|
||||
#endif
|
||||
case IPPROTO_TCP:
|
||||
return constant_to_sym(cmsg_type, intern_tcp_optname);
|
||||
return constant_to_sym(cmsg_type, rsock_intern_tcp_optname);
|
||||
case IPPROTO_UDP:
|
||||
return constant_to_sym(cmsg_type, intern_udp_optname);
|
||||
return constant_to_sym(cmsg_type, rsock_intern_udp_optname);
|
||||
default:
|
||||
return INT2NUM(cmsg_type);
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ ip_cmsg_type_to_sym(int level, int cmsg_type)
|
|||
static VALUE
|
||||
ancillary_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE data)
|
||||
{
|
||||
int family = family_arg(vfamily);
|
||||
int level = level_arg(family, vlevel);
|
||||
int type = cmsg_type_arg(family, level, vtype);
|
||||
int family = rsock_family_arg(vfamily);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int type = rsock_cmsg_type_arg(family, level, vtype);
|
||||
StringValue(data);
|
||||
rb_ivar_set(self, rb_intern("family"), INT2NUM(family));
|
||||
rb_ivar_set(self, rb_intern("level"), INT2NUM(level));
|
||||
|
@ -361,9 +361,9 @@ ancillary_timestamp(VALUE self)
|
|||
static VALUE
|
||||
ancillary_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE vtype, VALUE integer)
|
||||
{
|
||||
int family = family_arg(vfamily);
|
||||
int level = level_arg(family, vlevel);
|
||||
int type = cmsg_type_arg(family, level, vtype);
|
||||
int family = rsock_family_arg(vfamily);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int type = rsock_cmsg_type_arg(family, level, vtype);
|
||||
int i = NUM2INT(integer);
|
||||
return ancdata_new(family, level, type, rb_str_new((char*)&i, sizeof(i)));
|
||||
}
|
||||
|
@ -498,11 +498,11 @@ ancillary_ip_pktinfo(VALUE self)
|
|||
|
||||
sa.sin_family = AF_INET;
|
||||
memcpy(&sa.sin_addr, &pktinfo.ipi_addr, sizeof(sa.sin_addr));
|
||||
v_addr = addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
|
||||
v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
|
||||
|
||||
sa.sin_family = AF_INET;
|
||||
memcpy(&sa.sin_addr, &pktinfo.ipi_spec_dst, sizeof(sa.sin_addr));
|
||||
v_spec_dst = addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
|
||||
v_spec_dst = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET, 0, 0, Qnil, Qnil);
|
||||
|
||||
return rb_ary_new3(3, v_addr, UINT2NUM(pktinfo.ipi_ifindex), v_spec_dst);
|
||||
#else
|
||||
|
@ -603,7 +603,7 @@ ancillary_ipv6_pktinfo(VALUE self)
|
|||
VALUE v_addr;
|
||||
|
||||
extract_ipv6_pktinfo(self, &pktinfo, &sa);
|
||||
v_addr = addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
|
||||
v_addr = rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
|
||||
return rb_ary_new3(2, v_addr, UINT2NUM(pktinfo.ipi6_ifindex));
|
||||
#else
|
||||
rb_notimplement();
|
||||
|
@ -631,7 +631,7 @@ ancillary_ipv6_pktinfo_addr(VALUE self)
|
|||
struct in6_pktinfo pktinfo;
|
||||
struct sockaddr_in6 sa;
|
||||
extract_ipv6_pktinfo(self, &pktinfo, &sa);
|
||||
return addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
|
||||
return rsock_addrinfo_new((struct sockaddr *)&sa, sizeof(sa), PF_INET6, 0, 0, Qnil, Qnil);
|
||||
#else
|
||||
rb_notimplement();
|
||||
#endif
|
||||
|
@ -963,7 +963,7 @@ ancillary_inspect(VALUE self)
|
|||
|
||||
ret = rb_sprintf("#<%s:", rb_obj_classname(self));
|
||||
|
||||
family_id = intern_family_noprefix(family);
|
||||
family_id = rsock_intern_family_noprefix(family);
|
||||
if (family_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(family_id));
|
||||
else
|
||||
|
@ -972,14 +972,14 @@ ancillary_inspect(VALUE self)
|
|||
if (level == SOL_SOCKET) {
|
||||
rb_str_cat2(ret, " SOCKET");
|
||||
|
||||
type_id = intern_scm_optname(type);
|
||||
type_id = rsock_intern_scm_optname(type);
|
||||
if (type_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(type_id));
|
||||
else
|
||||
rb_str_catf(ret, " cmsg_type:%d", type);
|
||||
}
|
||||
else if (IS_IP_FAMILY(family)) {
|
||||
level_id = intern_iplevel(level);
|
||||
level_id = rsock_intern_iplevel(level);
|
||||
if (level_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(level_id));
|
||||
else
|
||||
|
@ -1088,8 +1088,8 @@ static VALUE
|
|||
ancillary_cmsg_is_p(VALUE self, VALUE vlevel, VALUE vtype)
|
||||
{
|
||||
int family = ancillary_family(self);
|
||||
int level = level_arg(family, vlevel);
|
||||
int type = cmsg_type_arg(family, level, vtype);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int type = rsock_cmsg_type_arg(family, level, vtype);
|
||||
|
||||
if (ancillary_level(self) == level &&
|
||||
ancillary_type(self) == type)
|
||||
|
@ -1187,8 +1187,8 @@ bsock_sendmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
vtype = rb_funcall(elt, rb_intern("type"), 0);
|
||||
cdata = rb_funcall(elt, rb_intern("data"), 0);
|
||||
}
|
||||
level = level_arg(family, vlevel);
|
||||
type = cmsg_type_arg(family, level, vtype);
|
||||
level = rsock_level_arg(family, vlevel);
|
||||
type = rsock_cmsg_type_arg(family, level, vtype);
|
||||
StringValue(cdata);
|
||||
oldlen = RSTRING_LEN(controls_str);
|
||||
cspace = CMSG_SPACE(RSTRING_LEN(cdata));
|
||||
|
@ -1423,7 +1423,7 @@ make_io_for_unix_rights(VALUE ctl, struct cmsghdr *cmh, char *msg_end)
|
|||
if (fstat(fd, &stbuf) == -1)
|
||||
rb_raise(rb_eSocket, "invalid fd in SCM_RIGHTS");
|
||||
if (S_ISSOCK(stbuf.st_mode))
|
||||
io = init_sock(rb_obj_alloc(rb_cSocket), fd);
|
||||
io = rsock_init_sock(rb_obj_alloc(rb_cSocket), fd);
|
||||
else
|
||||
io = rb_io_fdopen(fd, O_RDWR, NULL);
|
||||
ary = rb_attr_get(ctl, rb_intern("unix_rights"));
|
||||
|
@ -1640,7 +1640,7 @@ bsock_recvmsg_internal(int argc, VALUE *argv, VALUE sock, int nonblock)
|
|||
}
|
||||
|
||||
ret = rb_ary_new3(3, dat_str,
|
||||
io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
|
||||
rsock_io_socket_addrinfo(sock, mh.msg_name, mh.msg_namelen),
|
||||
#if defined(HAVE_ST_MSG_CONTROL)
|
||||
INT2NUM(mh.msg_flags)
|
||||
#else
|
||||
|
|
|
@ -25,7 +25,7 @@ static VALUE
|
|||
bsock_s_for_fd(VALUE klass, VALUE fd)
|
||||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE sock = init_sock(rb_obj_alloc(klass), NUM2INT(fd));
|
||||
VALUE sock = rsock_init_sock(rb_obj_alloc(klass), NUM2INT(fd));
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
|
||||
|
@ -73,7 +73,7 @@ bsock_shutdown(int argc, VALUE *argv, VALUE sock)
|
|||
if (howto == Qnil)
|
||||
how = SHUT_RDWR;
|
||||
else {
|
||||
how = shutdown_how_arg(howto);
|
||||
how = rsock_shutdown_how_arg(howto);
|
||||
if (how != SHUT_WR && how != SHUT_RD && how != SHUT_RDWR) {
|
||||
rb_raise(rb_eArgError, "`how' should be either :SHUT_RD, :SHUT_WR, :SHUT_RDWR");
|
||||
}
|
||||
|
@ -213,8 +213,8 @@ bsock_setsockopt(int argc, VALUE *argv, VALUE sock)
|
|||
rb_secure(2);
|
||||
GetOpenFile(sock, fptr);
|
||||
family = rb_sock_getfamily(fptr->fd);
|
||||
level = level_arg(family, lev);
|
||||
option = optname_arg(family, level, optname);
|
||||
level = rsock_level_arg(family, lev);
|
||||
option = rsock_optname_arg(family, level, optname);
|
||||
|
||||
switch (TYPE(val)) {
|
||||
case T_FIXNUM:
|
||||
|
@ -296,8 +296,8 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
family = rb_sock_getfamily(fptr->fd);
|
||||
level = level_arg(family, lev);
|
||||
option = optname_arg(family, level, optname);
|
||||
level = rsock_level_arg(family, lev);
|
||||
option = rsock_optname_arg(family, level, optname);
|
||||
len = 256;
|
||||
buf = ALLOCA_N(char,len);
|
||||
|
||||
|
@ -306,7 +306,7 @@ bsock_getsockopt(VALUE sock, VALUE lev, VALUE optname)
|
|||
if (getsockopt(fptr->fd, level, option, buf, &len) < 0)
|
||||
rb_sys_fail_path(fptr->pathv);
|
||||
|
||||
return sockopt_new(family, level, option, rb_str_new(buf, len));
|
||||
return rsock_sockopt_new(family, level, option, rb_str_new(buf, len));
|
||||
#else
|
||||
rb_notimplement();
|
||||
#endif
|
||||
|
@ -440,7 +440,7 @@ bsock_local_address(VALUE sock)
|
|||
GetOpenFile(sock, fptr);
|
||||
if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
|
||||
rb_sys_fail("getsockname(2)");
|
||||
return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
|
||||
return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -468,7 +468,7 @@ bsock_remote_address(VALUE sock)
|
|||
GetOpenFile(sock, fptr);
|
||||
if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0)
|
||||
rb_sys_fail("getpeername(2)");
|
||||
return fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
|
||||
return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -489,9 +489,9 @@ bsock_remote_address(VALUE sock)
|
|||
* }
|
||||
*/
|
||||
VALUE
|
||||
bsock_send(int argc, VALUE *argv, VALUE sock)
|
||||
rsock_bsock_send(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
struct send_arg arg;
|
||||
struct rsock_send_arg arg;
|
||||
VALUE flags, to;
|
||||
rb_io_t *fptr;
|
||||
int n;
|
||||
|
@ -506,10 +506,10 @@ bsock_send(int argc, VALUE *argv, VALUE sock)
|
|||
to = rb_str_new4(to);
|
||||
arg.to = (struct sockaddr *)RSTRING_PTR(to);
|
||||
arg.tolen = RSTRING_LEN(to);
|
||||
func = sendto_blocking;
|
||||
func = rsock_sendto_blocking;
|
||||
}
|
||||
else {
|
||||
func = send_blocking;
|
||||
func = rsock_send_blocking;
|
||||
}
|
||||
GetOpenFile(sock, fptr);
|
||||
arg.fd = fptr->fd;
|
||||
|
@ -596,7 +596,7 @@ bsock_do_not_reverse_lookup_set(VALUE sock, VALUE state)
|
|||
static VALUE
|
||||
bsock_recv(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom(sock, argc, argv, RECV_RECV);
|
||||
return rsock_s_recvfrom(sock, argc, argv, RECV_RECV);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -639,7 +639,7 @@ bsock_recv(int argc, VALUE *argv, VALUE sock)
|
|||
static VALUE
|
||||
bsock_recv_nonblock(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom_nonblock(sock, argc, argv, RECV_RECV);
|
||||
return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_RECV);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -653,7 +653,7 @@ bsock_recv_nonblock(int argc, VALUE *argv, VALUE sock)
|
|||
static VALUE
|
||||
bsock_do_not_rev_lookup(void)
|
||||
{
|
||||
return do_not_reverse_lookup?Qtrue:Qfalse;
|
||||
return rsock_do_not_reverse_lookup?Qtrue:Qfalse;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -676,7 +676,7 @@ static VALUE
|
|||
bsock_do_not_rev_lookup_set(VALUE self, VALUE val)
|
||||
{
|
||||
rb_secure(4);
|
||||
do_not_reverse_lookup = RTEST(val);
|
||||
rsock_do_not_reverse_lookup = RTEST(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -705,7 +705,7 @@ Init_basicsocket(void)
|
|||
rb_define_method(rb_cBasicSocket, "getpeereid", bsock_getpeereid, 0);
|
||||
rb_define_method(rb_cBasicSocket, "local_address", bsock_local_address, 0);
|
||||
rb_define_method(rb_cBasicSocket, "remote_address", bsock_remote_address, 0);
|
||||
rb_define_method(rb_cBasicSocket, "send", bsock_send, -1);
|
||||
rb_define_method(rb_cBasicSocket, "send", rsock_bsock_send, -1);
|
||||
rb_define_method(rb_cBasicSocket, "recv", bsock_recv, -1);
|
||||
rb_define_method(rb_cBasicSocket, "recv_nonblock", bsock_recv_nonblock, -1);
|
||||
rb_define_method(rb_cBasicSocket, "do_not_reverse_lookup", bsock_do_not_reverse_lookup, 0);
|
||||
|
|
|
@ -40,48 +40,48 @@ constant_arg(VALUE arg, int (*str_to_int)(const char*, int, int*), const char *e
|
|||
}
|
||||
|
||||
int
|
||||
family_arg(VALUE domain)
|
||||
rsock_family_arg(VALUE domain)
|
||||
{
|
||||
/* convert AF_INET, etc. */
|
||||
return constant_arg(domain, family_to_int, "unknown socket domain");
|
||||
return constant_arg(domain, rsock_family_to_int, "unknown socket domain");
|
||||
}
|
||||
|
||||
int
|
||||
socktype_arg(VALUE type)
|
||||
rsock_socktype_arg(VALUE type)
|
||||
{
|
||||
/* convert SOCK_STREAM, etc. */
|
||||
return constant_arg(type, socktype_to_int, "unknown socket type");
|
||||
return constant_arg(type, rsock_socktype_to_int, "unknown socket type");
|
||||
}
|
||||
|
||||
int
|
||||
level_arg(int family, VALUE level)
|
||||
rsock_level_arg(int family, VALUE level)
|
||||
{
|
||||
/* convert SOL_SOCKET, IPPROTO_TCP, etc. */
|
||||
if (IS_IP_FAMILY(family)) {
|
||||
return constant_arg(level, ip_level_to_int, "unknown protocol level");
|
||||
return constant_arg(level, rsock_ip_level_to_int, "unknown protocol level");
|
||||
}
|
||||
else {
|
||||
return constant_arg(level, unknown_level_to_int, "unknown protocol level");
|
||||
return constant_arg(level, rsock_unknown_level_to_int, "unknown protocol level");
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
optname_arg(int family, int level, VALUE optname)
|
||||
rsock_optname_arg(int family, int level, VALUE optname)
|
||||
{
|
||||
if (IS_IP_FAMILY(family)) {
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_arg(optname, so_optname_to_int, "unknown socket level option name");
|
||||
return constant_arg(optname, rsock_so_optname_to_int, "unknown socket level option name");
|
||||
case IPPROTO_IP:
|
||||
return constant_arg(optname, ip_optname_to_int, "unknown IP level option name");
|
||||
return constant_arg(optname, rsock_ip_optname_to_int, "unknown IP level option name");
|
||||
#ifdef IPPROTO_IPV6
|
||||
case IPPROTO_IPV6:
|
||||
return constant_arg(optname, ipv6_optname_to_int, "unknown IPv6 level option name");
|
||||
return constant_arg(optname, rsock_ipv6_optname_to_int, "unknown IPv6 level option name");
|
||||
#endif
|
||||
case IPPROTO_TCP:
|
||||
return constant_arg(optname, tcp_optname_to_int, "unknown TCP level option name");
|
||||
return constant_arg(optname, rsock_tcp_optname_to_int, "unknown TCP level option name");
|
||||
case IPPROTO_UDP:
|
||||
return constant_arg(optname, udp_optname_to_int, "unknown UDP level option name");
|
||||
return constant_arg(optname, rsock_udp_optname_to_int, "unknown UDP level option name");
|
||||
default:
|
||||
return NUM2INT(optname);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ optname_arg(int family, int level, VALUE optname)
|
|||
else {
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_arg(optname, so_optname_to_int, "unknown socket level option name");
|
||||
return constant_arg(optname, rsock_so_optname_to_int, "unknown socket level option name");
|
||||
default:
|
||||
return NUM2INT(optname);
|
||||
}
|
||||
|
@ -97,22 +97,22 @@ optname_arg(int family, int level, VALUE optname)
|
|||
}
|
||||
|
||||
int
|
||||
cmsg_type_arg(int family, int level, VALUE type)
|
||||
rsock_cmsg_type_arg(int family, int level, VALUE type)
|
||||
{
|
||||
if (IS_IP_FAMILY(family)) {
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_arg(type, scm_optname_to_int, "unknown UNIX control message");
|
||||
return constant_arg(type, rsock_scm_optname_to_int, "unknown UNIX control message");
|
||||
case IPPROTO_IP:
|
||||
return constant_arg(type, ip_optname_to_int, "unknown IP control message");
|
||||
return constant_arg(type, rsock_ip_optname_to_int, "unknown IP control message");
|
||||
#ifdef INET6
|
||||
case IPPROTO_IPV6:
|
||||
return constant_arg(type, ipv6_optname_to_int, "unknown IPv6 control message");
|
||||
return constant_arg(type, rsock_ipv6_optname_to_int, "unknown IPv6 control message");
|
||||
#endif
|
||||
case IPPROTO_TCP:
|
||||
return constant_arg(type, tcp_optname_to_int, "unknown TCP control message");
|
||||
return constant_arg(type, rsock_tcp_optname_to_int, "unknown TCP control message");
|
||||
case IPPROTO_UDP:
|
||||
return constant_arg(type, udp_optname_to_int, "unknown UDP control message");
|
||||
return constant_arg(type, rsock_udp_optname_to_int, "unknown UDP control message");
|
||||
default:
|
||||
return NUM2INT(type);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ cmsg_type_arg(int family, int level, VALUE type)
|
|||
else {
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_arg(type, scm_optname_to_int, "unknown UNIX control message");
|
||||
return constant_arg(type, rsock_scm_optname_to_int, "unknown UNIX control message");
|
||||
default:
|
||||
return NUM2INT(type);
|
||||
}
|
||||
|
@ -128,10 +128,10 @@ cmsg_type_arg(int family, int level, VALUE type)
|
|||
}
|
||||
|
||||
int
|
||||
shutdown_how_arg(VALUE how)
|
||||
rsock_shutdown_how_arg(VALUE how)
|
||||
{
|
||||
/* convert SHUT_RD, SHUT_WR, SHUT_RDWR. */
|
||||
return constant_arg(how, shutdown_how_to_int, "unknown shutdown argument");
|
||||
return constant_arg(how, rsock_shutdown_how_to_int, "unknown shutdown argument");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -28,10 +28,10 @@ VALUE rb_eSocket;
|
|||
VALUE rb_cSOCKSSocket;
|
||||
#endif
|
||||
|
||||
int do_not_reverse_lookup = 0;
|
||||
int rsock_do_not_reverse_lookup = 0;
|
||||
|
||||
void
|
||||
raise_socket_error(const char *reason, int error)
|
||||
rsock_raise_socket_error(const char *reason, int error)
|
||||
{
|
||||
#ifdef EAI_SYSTEM
|
||||
if (error == EAI_SYSTEM) rb_sys_fail(reason);
|
||||
|
@ -40,7 +40,7 @@ raise_socket_error(const char *reason, int error)
|
|||
}
|
||||
|
||||
VALUE
|
||||
init_sock(VALUE sock, int fd)
|
||||
rsock_init_sock(VALUE sock, int fd)
|
||||
{
|
||||
rb_io_t *fp;
|
||||
|
||||
|
@ -48,7 +48,7 @@ init_sock(VALUE sock, int fd)
|
|||
fp->fd = fd;
|
||||
fp->mode = FMODE_READWRITE|FMODE_DUPLEX;
|
||||
rb_io_ascii8bit_binmode(sock);
|
||||
if (do_not_reverse_lookup) {
|
||||
if (rsock_do_not_reverse_lookup) {
|
||||
fp->mode |= FMODE_NOREVLOOKUP;
|
||||
}
|
||||
rb_io_synchronized(fp);
|
||||
|
@ -57,18 +57,18 @@ init_sock(VALUE sock, int fd)
|
|||
}
|
||||
|
||||
VALUE
|
||||
sendto_blocking(void *data)
|
||||
rsock_sendto_blocking(void *data)
|
||||
{
|
||||
struct send_arg *arg = data;
|
||||
struct rsock_send_arg *arg = data;
|
||||
VALUE mesg = arg->mesg;
|
||||
return (VALUE)sendto(arg->fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg),
|
||||
arg->flags, arg->to, arg->tolen);
|
||||
}
|
||||
|
||||
VALUE
|
||||
send_blocking(void *data)
|
||||
rsock_send_blocking(void *data)
|
||||
{
|
||||
struct send_arg *arg = data;
|
||||
struct rsock_send_arg *arg = data;
|
||||
VALUE mesg = arg->mesg;
|
||||
return (VALUE)send(arg->fd, RSTRING_PTR(mesg), RSTRING_LEN(mesg),
|
||||
arg->flags);
|
||||
|
@ -90,7 +90,7 @@ recvfrom_blocking(void *data)
|
|||
}
|
||||
|
||||
VALUE
|
||||
s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
||||
rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
||||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE str, klass;
|
||||
|
@ -142,23 +142,23 @@ s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
}
|
||||
#endif
|
||||
if (arg.alen && arg.alen != sizeof(arg.buf)) /* OSX doesn't return a from result for connection-oriented sockets */
|
||||
return rb_assoc_new(str, ipaddr((struct sockaddr*)&arg.buf, fptr->mode & FMODE_NOREVLOOKUP));
|
||||
return rb_assoc_new(str, rsock_ipaddr((struct sockaddr*)&arg.buf, fptr->mode & FMODE_NOREVLOOKUP));
|
||||
else
|
||||
return rb_assoc_new(str, Qnil);
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
case RECV_UNIX:
|
||||
return rb_assoc_new(str, unixaddr((struct sockaddr_un*)&arg.buf, arg.alen));
|
||||
return rb_assoc_new(str, rsock_unixaddr((struct sockaddr_un*)&arg.buf, arg.alen));
|
||||
#endif
|
||||
case RECV_SOCKET:
|
||||
return rb_assoc_new(str, io_socket_addrinfo(sock, (struct sockaddr*)&arg.buf, arg.alen));
|
||||
return rb_assoc_new(str, rsock_io_socket_addrinfo(sock, (struct sockaddr*)&arg.buf, arg.alen));
|
||||
default:
|
||||
rb_bug("s_recvfrom called with bad value");
|
||||
rb_bug("rsock_s_recvfrom called with bad value");
|
||||
}
|
||||
}
|
||||
|
||||
VALUE
|
||||
s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
||||
rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
||||
{
|
||||
rb_io_t *fptr;
|
||||
VALUE str;
|
||||
|
@ -214,15 +214,15 @@ s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from)
|
|||
|
||||
case RECV_IP:
|
||||
if (alen && alen != sizeof(buf)) /* connection-oriented socket may not return a from result */
|
||||
addr = ipaddr((struct sockaddr*)&buf, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
addr = rsock_ipaddr((struct sockaddr*)&buf, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
break;
|
||||
|
||||
case RECV_SOCKET:
|
||||
addr = io_socket_addrinfo(sock, (struct sockaddr*)&buf, alen);
|
||||
addr = rsock_io_socket_addrinfo(sock, (struct sockaddr*)&buf, alen);
|
||||
break;
|
||||
|
||||
default:
|
||||
rb_bug("s_recvfrom_nonblock called with bad value");
|
||||
rb_bug("rsock_s_recvfrom_nonblock called with bad value");
|
||||
}
|
||||
return rb_assoc_new(str, addr);
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ make_fd_nonblock(int fd)
|
|||
}
|
||||
|
||||
VALUE
|
||||
s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
|
||||
rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len)
|
||||
{
|
||||
int fd2;
|
||||
|
||||
|
@ -477,7 +477,7 @@ s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen
|
|||
rb_sys_fail("accept(2)");
|
||||
}
|
||||
make_fd_nonblock(fd2);
|
||||
return init_sock(rb_obj_alloc(klass), fd2);
|
||||
return rsock_init_sock(rb_obj_alloc(klass), fd2);
|
||||
}
|
||||
|
||||
struct accept_arg {
|
||||
|
@ -494,7 +494,7 @@ accept_blocking(void *data)
|
|||
}
|
||||
|
||||
VALUE
|
||||
s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
|
||||
rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
|
||||
{
|
||||
int fd2;
|
||||
int retry = 0;
|
||||
|
@ -523,7 +523,7 @@ s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len)
|
|||
rb_sys_fail(0);
|
||||
}
|
||||
if (!klass) return INT2NUM(fd2);
|
||||
return init_sock(rb_obj_alloc(klass), fd2);
|
||||
return rsock_init_sock(rb_obj_alloc(klass), fd2);
|
||||
}
|
||||
|
||||
int rb_sock_getfamily(int sockfd)
|
||||
|
|
|
@ -104,12 +104,12 @@ init_inetsock_internal(struct inetsock_arg *arg)
|
|||
listen(fd, 5);
|
||||
|
||||
/* create new instance */
|
||||
return init_sock(arg->sock, fd);
|
||||
return rsock_init_sock(arg->sock, fd);
|
||||
}
|
||||
|
||||
VALUE
|
||||
init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
|
||||
VALUE local_host, VALUE local_serv, int type)
|
||||
rsock_init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv,
|
||||
VALUE local_host, VALUE local_serv, int type)
|
||||
{
|
||||
struct inetsock_arg arg;
|
||||
arg.sock = sock;
|
||||
|
@ -152,7 +152,7 @@ ip_addr(VALUE sock)
|
|||
|
||||
if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
|
||||
rb_sys_fail("getsockname(2)");
|
||||
return ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
return rsock_ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -179,7 +179,7 @@ ip_peeraddr(VALUE sock)
|
|||
|
||||
if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
|
||||
rb_sys_fail("getpeername(2)");
|
||||
return ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
return rsock_ipaddr((struct sockaddr*)&addr, fptr->mode & FMODE_NOREVLOOKUP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -206,7 +206,7 @@ ip_peeraddr(VALUE sock)
|
|||
static VALUE
|
||||
ip_recvfrom(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom(sock, argc, argv, RECV_IP);
|
||||
return rsock_s_recvfrom(sock, argc, argv, RECV_IP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -229,7 +229,7 @@ ip_s_getaddress(VALUE obj, VALUE host)
|
|||
memcpy(&addr, res->ai_addr, res->ai_addrlen);
|
||||
freeaddrinfo(res);
|
||||
|
||||
return make_ipaddr((struct sockaddr*)&addr);
|
||||
return rsock_make_ipaddr((struct sockaddr*)&addr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -240,32 +240,32 @@ def def_intern(func_name, pat, prefix_optional=nil)
|
|||
INTERN_DEFS << [vardef, gen_hash, decl, func]
|
||||
end
|
||||
|
||||
def_name_to_int("family_to_int", /\A(AF_|PF_)/, "AF_")
|
||||
def_name_to_int("socktype_to_int", /\ASOCK_/, "SOCK_")
|
||||
def_name_to_int("ipproto_to_int", /\AIPPROTO_/, "IPPROTO_")
|
||||
def_name_to_int("unknown_level_to_int", /\ASOL_SOCKET\z/, "SOL_")
|
||||
def_name_to_int("ip_level_to_int", /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
||||
def_name_to_int("so_optname_to_int", /\ASO_/, "SO_")
|
||||
def_name_to_int("ip_optname_to_int", /\AIP_/, "IP_")
|
||||
def_name_to_int("ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6")
|
||||
def_name_to_int("tcp_optname_to_int", /\ATCP_/, "TCP_")
|
||||
def_name_to_int("udp_optname_to_int", /\AUDP_/, "UDP_")
|
||||
def_name_to_int("shutdown_how_to_int", /\ASHUT_/, "SHUT_")
|
||||
def_name_to_int("scm_optname_to_int", /\ASCM_/, "SCM_")
|
||||
def_name_to_int("rsock_family_to_int", /\A(AF_|PF_)/, "AF_")
|
||||
def_name_to_int("rsock_socktype_to_int", /\ASOCK_/, "SOCK_")
|
||||
def_name_to_int("rsock_ipproto_to_int", /\AIPPROTO_/, "IPPROTO_")
|
||||
def_name_to_int("rsock_unknown_level_to_int", /\ASOL_SOCKET\z/, "SOL_")
|
||||
def_name_to_int("rsock_ip_level_to_int", /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
||||
def_name_to_int("rsock_so_optname_to_int", /\ASO_/, "SO_")
|
||||
def_name_to_int("rsock_ip_optname_to_int", /\AIP_/, "IP_")
|
||||
def_name_to_int("rsock_ipv6_optname_to_int", /\AIPV6_/, "IPV6_", "IPPROTO_IPV6")
|
||||
def_name_to_int("rsock_tcp_optname_to_int", /\ATCP_/, "TCP_")
|
||||
def_name_to_int("rsock_udp_optname_to_int", /\AUDP_/, "UDP_")
|
||||
def_name_to_int("rsock_shutdown_how_to_int", /\ASHUT_/, "SHUT_")
|
||||
def_name_to_int("rsock_scm_optname_to_int", /\ASCM_/, "SCM_")
|
||||
|
||||
def_intern('intern_family', /\AAF_/)
|
||||
def_intern('intern_family_noprefix', /\AAF_/, "AF_")
|
||||
def_intern('intern_protocol_family', /\APF_/)
|
||||
def_intern('intern_socktype', /\ASOCK_/)
|
||||
def_intern('intern_ipproto', /\AIPPROTO_/)
|
||||
def_intern('intern_iplevel', /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
||||
def_intern('intern_so_optname', /\ASO_/, "SO_")
|
||||
def_intern('intern_ip_optname', /\AIP_/, "IP_")
|
||||
def_intern('intern_ipv6_optname', /\AIPV6_/, "IPV6_")
|
||||
def_intern('intern_tcp_optname', /\ATCP_/, "TCP_")
|
||||
def_intern('intern_udp_optname', /\AUDP_/, "UDP_")
|
||||
def_intern('intern_scm_optname', /\ASCM_/, "SCM_")
|
||||
def_intern('intern_local_optname', /\ALOCAL_/, "LOCAL_")
|
||||
def_intern('rsock_intern_family', /\AAF_/)
|
||||
def_intern('rsock_intern_family_noprefix', /\AAF_/, "AF_")
|
||||
def_intern('rsock_intern_protocol_family', /\APF_/)
|
||||
def_intern('rsock_intern_socktype', /\ASOCK_/)
|
||||
def_intern('rsock_intern_ipproto', /\AIPPROTO_/)
|
||||
def_intern('rsock_intern_iplevel', /\A(SOL_SOCKET\z|IPPROTO_)/, /\A(SOL_|IPPROTO_)/)
|
||||
def_intern('rsock_intern_so_optname', /\ASO_/, "SO_")
|
||||
def_intern('rsock_intern_ip_optname', /\AIP_/, "IP_")
|
||||
def_intern('rsock_intern_ipv6_optname', /\AIPV6_/, "IPV6_")
|
||||
def_intern('rsock_intern_tcp_optname', /\ATCP_/, "TCP_")
|
||||
def_intern('rsock_intern_udp_optname', /\AUDP_/, "UDP_")
|
||||
def_intern('rsock_intern_scm_optname', /\ASCM_/, "SCM_")
|
||||
def_intern('rsock_intern_local_optname', /\ALOCAL_/, "LOCAL_")
|
||||
|
||||
result = ERB.new(<<'EOS', nil, '%').result(binding)
|
||||
/* autogenerated file */
|
||||
|
|
|
@ -18,17 +18,17 @@ optname_to_sym(int level, int optname)
|
|||
{
|
||||
switch (level) {
|
||||
case SOL_SOCKET:
|
||||
return constant_to_sym(optname, intern_so_optname);
|
||||
return constant_to_sym(optname, rsock_intern_so_optname);
|
||||
case IPPROTO_IP:
|
||||
return constant_to_sym(optname, intern_ip_optname);
|
||||
return constant_to_sym(optname, rsock_intern_ip_optname);
|
||||
#ifdef INET6
|
||||
case IPPROTO_IPV6:
|
||||
return constant_to_sym(optname, intern_ipv6_optname);
|
||||
return constant_to_sym(optname, rsock_intern_ipv6_optname);
|
||||
#endif
|
||||
case IPPROTO_TCP:
|
||||
return constant_to_sym(optname, intern_tcp_optname);
|
||||
return constant_to_sym(optname, rsock_intern_tcp_optname);
|
||||
case IPPROTO_UDP:
|
||||
return constant_to_sym(optname, intern_udp_optname);
|
||||
return constant_to_sym(optname, rsock_intern_udp_optname);
|
||||
default:
|
||||
return INT2NUM(optname);
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ optname_to_sym(int level, int optname)
|
|||
static VALUE
|
||||
sockopt_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE data)
|
||||
{
|
||||
int family = family_arg(vfamily);
|
||||
int level = level_arg(family, vlevel);
|
||||
int optname = optname_arg(family, level, voptname);
|
||||
int family = rsock_family_arg(vfamily);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int optname = rsock_optname_arg(family, level, voptname);
|
||||
StringValue(data);
|
||||
rb_ivar_set(self, rb_intern("family"), INT2NUM(family));
|
||||
rb_ivar_set(self, rb_intern("level"), INT2NUM(level));
|
||||
|
@ -59,7 +59,7 @@ sockopt_initialize(VALUE self, VALUE vfamily, VALUE vlevel, VALUE voptname, VALU
|
|||
}
|
||||
|
||||
VALUE
|
||||
sockopt_new(int family, int level, int optname, VALUE data)
|
||||
rsock_sockopt_new(int family, int level, int optname, VALUE data)
|
||||
{
|
||||
NEWOBJ(obj, struct RObject);
|
||||
OBJSETUP(obj, rb_cSockOpt, T_OBJECT);
|
||||
|
@ -156,11 +156,11 @@ sockopt_data(VALUE self)
|
|||
static VALUE
|
||||
sockopt_s_int(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vint)
|
||||
{
|
||||
int family = family_arg(vfamily);
|
||||
int level = level_arg(family, vlevel);
|
||||
int optname = optname_arg(family, level, voptname);
|
||||
int family = rsock_family_arg(vfamily);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int optname = rsock_optname_arg(family, level, voptname);
|
||||
int i = NUM2INT(vint);
|
||||
return sockopt_new(family, level, optname, rb_str_new((char*)&i, sizeof(i)));
|
||||
return rsock_sockopt_new(family, level, optname, rb_str_new((char*)&i, sizeof(i)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -204,11 +204,11 @@ sockopt_int(VALUE self)
|
|||
static VALUE
|
||||
sockopt_s_bool(VALUE klass, VALUE vfamily, VALUE vlevel, VALUE voptname, VALUE vbool)
|
||||
{
|
||||
int family = family_arg(vfamily);
|
||||
int level = level_arg(family, vlevel);
|
||||
int optname = optname_arg(family, level, voptname);
|
||||
int family = rsock_family_arg(vfamily);
|
||||
int level = rsock_level_arg(family, vlevel);
|
||||
int optname = rsock_optname_arg(family, level, voptname);
|
||||
int i = RTEST(vbool) ? 1 : 0;
|
||||
return sockopt_new(family, level, optname, rb_str_new((char*)&i, sizeof(i)));
|
||||
return rsock_sockopt_new(family, level, optname, rb_str_new((char*)&i, sizeof(i)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -258,7 +258,7 @@ sockopt_s_linger(VALUE klass, VALUE vonoff, VALUE vsecs)
|
|||
else
|
||||
l.l_onoff = RTEST(vonoff) ? 1 : 0;
|
||||
l.l_linger = NUM2INT(vsecs);
|
||||
return sockopt_new(AF_UNSPEC, SOL_SOCKET, SO_LINGER, rb_str_new((char*)&l, sizeof(l)));
|
||||
return rsock_sockopt_new(AF_UNSPEC, SOL_SOCKET, SO_LINGER, rb_str_new((char*)&l, sizeof(l)));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -369,7 +369,7 @@ inspect_socktype(int level, int optname, VALUE data, VALUE ret)
|
|||
int i;
|
||||
ID id;
|
||||
memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
|
||||
id = intern_socktype(i);
|
||||
id = rsock_intern_socktype(i);
|
||||
if (id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(id));
|
||||
else
|
||||
|
@ -468,7 +468,7 @@ sockopt_inspect(VALUE self)
|
|||
|
||||
ret = rb_sprintf("#<%s:", rb_obj_classname(self));
|
||||
|
||||
family_id = intern_family_noprefix(family);
|
||||
family_id = rsock_intern_family_noprefix(family);
|
||||
if (family_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(family_id));
|
||||
else
|
||||
|
@ -477,7 +477,7 @@ sockopt_inspect(VALUE self)
|
|||
if (level == SOL_SOCKET) {
|
||||
rb_str_cat2(ret, " SOCKET");
|
||||
|
||||
optname_id = intern_so_optname(optname);
|
||||
optname_id = rsock_intern_so_optname(optname);
|
||||
if (optname_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(optname_id));
|
||||
else
|
||||
|
@ -487,7 +487,7 @@ sockopt_inspect(VALUE self)
|
|||
else if (family == AF_UNIX) {
|
||||
rb_str_catf(ret, " level:%d", level);
|
||||
|
||||
optname_id = intern_local_optname(optname);
|
||||
optname_id = rsock_intern_local_optname(optname);
|
||||
if (optname_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(optname_id));
|
||||
else
|
||||
|
@ -495,7 +495,7 @@ sockopt_inspect(VALUE self)
|
|||
}
|
||||
#endif
|
||||
else if (IS_IP_FAMILY(family)) {
|
||||
level_id = intern_iplevel(level);
|
||||
level_id = rsock_intern_iplevel(level);
|
||||
if (level_id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(level_id));
|
||||
else
|
||||
|
|
|
@ -186,12 +186,12 @@ make_ipaddr0(struct sockaddr *addr, char *buf, size_t len)
|
|||
|
||||
error = rb_getnameinfo(addr, SA_LEN(addr), buf, len, NULL, 0, NI_NUMERICHOST);
|
||||
if (error) {
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
}
|
||||
|
||||
VALUE
|
||||
make_ipaddr(struct sockaddr *addr)
|
||||
rsock_make_ipaddr(struct sockaddr *addr)
|
||||
{
|
||||
char hbuf[1024];
|
||||
|
||||
|
@ -312,7 +312,7 @@ sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_ha
|
|||
if (hostp && hostp[strlen(hostp)-1] == '\n') {
|
||||
rb_raise(rb_eSocket, "newline at the end of hostname");
|
||||
}
|
||||
raise_socket_error("getaddrinfo", error);
|
||||
rsock_raise_socket_error("getaddrinfo", error);
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
|
@ -349,7 +349,7 @@ sock_addrinfo(VALUE host, VALUE port, int socktype, int flags)
|
|||
}
|
||||
|
||||
VALUE
|
||||
ipaddr(struct sockaddr *sockaddr, int norevlookup)
|
||||
rsock_ipaddr(struct sockaddr *sockaddr, int norevlookup)
|
||||
{
|
||||
VALUE family, port, addr1, addr2;
|
||||
VALUE ary;
|
||||
|
@ -357,7 +357,7 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
|
|||
char hbuf[1024], pbuf[1024];
|
||||
ID id;
|
||||
|
||||
id = intern_family(sockaddr->sa_family);
|
||||
id = rsock_intern_family(sockaddr->sa_family);
|
||||
if (id) {
|
||||
family = rb_str_dup(rb_id2str(id));
|
||||
}
|
||||
|
@ -377,7 +377,7 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
|
|||
error = rb_getnameinfo(sockaddr, SA_LEN(sockaddr), hbuf, sizeof(hbuf),
|
||||
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (error) {
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
addr2 = rb_str_new2(hbuf);
|
||||
if (addr1 == Qnil) {
|
||||
|
@ -391,7 +391,7 @@ ipaddr(struct sockaddr *sockaddr, int norevlookup)
|
|||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
const char*
|
||||
unixpath(struct sockaddr_un *sockaddr, socklen_t len)
|
||||
rsock_unixpath(struct sockaddr_un *sockaddr, socklen_t len)
|
||||
{
|
||||
if (sockaddr->sun_path < (char*)sockaddr + len)
|
||||
return sockaddr->sun_path;
|
||||
|
@ -400,10 +400,10 @@ unixpath(struct sockaddr_un *sockaddr, socklen_t len)
|
|||
}
|
||||
|
||||
VALUE
|
||||
unixaddr(struct sockaddr_un *sockaddr, socklen_t len)
|
||||
rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len)
|
||||
{
|
||||
return rb_assoc_new(rb_str_new2("AF_UNIX"),
|
||||
rb_str_new2(unixpath(sockaddr, len)));
|
||||
rb_str_new2(rsock_unixpath(sockaddr, len)));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -457,7 +457,7 @@ make_hostent_internal(struct hostent_arg *arg)
|
|||
}
|
||||
|
||||
VALUE
|
||||
make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t))
|
||||
rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t))
|
||||
{
|
||||
struct hostent_arg arg;
|
||||
|
||||
|
@ -551,9 +551,9 @@ init_addrinfo(rb_addrinfo_t *rai, struct sockaddr *sa, size_t len,
|
|||
}
|
||||
|
||||
VALUE
|
||||
addrinfo_new(struct sockaddr *addr, socklen_t len,
|
||||
int family, int socktype, int protocol,
|
||||
VALUE canonname, VALUE inspectname)
|
||||
rsock_addrinfo_new(struct sockaddr *addr, socklen_t len,
|
||||
int family, int socktype, int protocol,
|
||||
VALUE canonname, VALUE inspectname)
|
||||
{
|
||||
VALUE a;
|
||||
rb_addrinfo_t *rai;
|
||||
|
@ -572,10 +572,10 @@ call_getaddrinfo(VALUE node, VALUE service,
|
|||
struct addrinfo hints, *res;
|
||||
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
hints.ai_family = NIL_P(family) ? PF_UNSPEC : family_arg(family);
|
||||
hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family);
|
||||
|
||||
if (!NIL_P(socktype)) {
|
||||
hints.ai_socktype = socktype_arg(socktype);
|
||||
hints.ai_socktype = rsock_socktype_arg(socktype);
|
||||
}
|
||||
if (!NIL_P(protocol)) {
|
||||
hints.ai_protocol = NUM2INT(protocol);
|
||||
|
@ -676,9 +676,9 @@ addrinfo_firstonly_new(VALUE node, VALUE service, VALUE family, VALUE socktype,
|
|||
OBJ_FREEZE(canonname);
|
||||
}
|
||||
|
||||
ret = addrinfo_new(res->ai_addr, res->ai_addrlen,
|
||||
res->ai_family, res->ai_socktype, res->ai_protocol,
|
||||
canonname, inspectname);
|
||||
ret = rsock_addrinfo_new(res->ai_addr, res->ai_addrlen,
|
||||
res->ai_family, res->ai_socktype, res->ai_protocol,
|
||||
canonname, inspectname);
|
||||
|
||||
freeaddrinfo(res);
|
||||
return ret;
|
||||
|
@ -705,9 +705,9 @@ addrinfo_list_new(VALUE node, VALUE service, VALUE family, VALUE socktype, VALUE
|
|||
OBJ_FREEZE(canonname);
|
||||
}
|
||||
|
||||
addr = addrinfo_new(r->ai_addr, r->ai_addrlen,
|
||||
r->ai_family, r->ai_socktype, r->ai_protocol,
|
||||
canonname, inspectname);
|
||||
addr = rsock_addrinfo_new(r->ai_addr, r->ai_addrlen,
|
||||
r->ai_family, r->ai_socktype, r->ai_protocol,
|
||||
canonname, inspectname);
|
||||
|
||||
rb_ary_push(ret, addr);
|
||||
}
|
||||
|
@ -800,8 +800,8 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
|
|||
|
||||
rb_scan_args(argc, argv, "13", &sockaddr_arg, &pfamily, &socktype, &protocol);
|
||||
|
||||
i_pfamily = NIL_P(pfamily) ? PF_UNSPEC : family_arg(pfamily);
|
||||
i_socktype = NIL_P(socktype) ? 0 : socktype_arg(socktype);
|
||||
i_pfamily = NIL_P(pfamily) ? PF_UNSPEC : rsock_family_arg(pfamily);
|
||||
i_socktype = NIL_P(socktype) ? 0 : rsock_socktype_arg(socktype);
|
||||
i_protocol = NIL_P(protocol) ? 0 : NUM2INT(protocol);
|
||||
|
||||
sockaddr_ary = rb_check_array_type(sockaddr_arg);
|
||||
|
@ -809,7 +809,7 @@ addrinfo_initialize(int argc, VALUE *argv, VALUE self)
|
|||
VALUE afamily = rb_ary_entry(sockaddr_ary, 0);
|
||||
int af;
|
||||
StringValue(afamily);
|
||||
if (family_to_int(RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1)
|
||||
if (rsock_family_to_int(RSTRING_PTR(afamily), RSTRING_LEN(afamily), &af) == -1)
|
||||
rb_raise(rb_eSocket, "unknown address family: %s", StringValueCStr(afamily));
|
||||
switch (af) {
|
||||
case AF_INET: /* ["AF_INET", 46102, "localhost.localdomain", "127.0.0.1"] */
|
||||
|
@ -934,7 +934,7 @@ inspect_sockaddr(VALUE addrinfo, VALUE ret)
|
|||
hbuf, sizeof(hbuf), NULL, 0,
|
||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||
if (error) {
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
if (addr->sin6_port == 0) {
|
||||
rb_str_cat2(ret, hbuf);
|
||||
|
@ -999,7 +999,7 @@ inspect_sockaddr(VALUE addrinfo, VALUE ret)
|
|||
|
||||
default:
|
||||
{
|
||||
ID id = intern_family(rai->addr.ss_family);
|
||||
ID id = rsock_intern_family(rai->addr.ss_family);
|
||||
if (id == 0)
|
||||
rb_str_catf(ret, "unknown address family %d", rai->addr.ss_family);
|
||||
else
|
||||
|
@ -1034,7 +1034,7 @@ addrinfo_inspect(VALUE self)
|
|||
inspect_sockaddr(self, ret);
|
||||
|
||||
if (rai->pfamily && ai_get_afamily(rai) != rai->pfamily) {
|
||||
ID id = intern_protocol_family(rai->pfamily);
|
||||
ID id = rsock_intern_protocol_family(rai->pfamily);
|
||||
if (id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(id));
|
||||
else
|
||||
|
@ -1055,7 +1055,7 @@ addrinfo_inspect(VALUE self)
|
|||
}
|
||||
else {
|
||||
if (rai->socktype) {
|
||||
ID id = intern_socktype(rai->socktype);
|
||||
ID id = rsock_intern_socktype(rai->socktype);
|
||||
if (id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(id));
|
||||
else
|
||||
|
@ -1064,7 +1064,7 @@ addrinfo_inspect(VALUE self)
|
|||
|
||||
if (rai->protocol) {
|
||||
if (internet_p) {
|
||||
ID id = intern_ipproto(rai->protocol);
|
||||
ID id = rsock_intern_ipproto(rai->protocol);
|
||||
if (id)
|
||||
rb_str_catf(ret, " %s", rb_id2name(id));
|
||||
else
|
||||
|
@ -1117,7 +1117,7 @@ addrinfo_mdump(VALUE self)
|
|||
int afamily_int = ai_get_afamily(rai);
|
||||
ID id;
|
||||
|
||||
id = intern_protocol_family(rai->pfamily);
|
||||
id = rsock_intern_protocol_family(rai->pfamily);
|
||||
if (id == 0)
|
||||
rb_raise(rb_eSocket, "unknown protocol family: %d", rai->pfamily);
|
||||
pfamily = rb_id2str(id);
|
||||
|
@ -1125,7 +1125,7 @@ addrinfo_mdump(VALUE self)
|
|||
if (rai->socktype == 0)
|
||||
socktype = INT2FIX(0);
|
||||
else {
|
||||
id = intern_socktype(rai->socktype);
|
||||
id = rsock_intern_socktype(rai->socktype);
|
||||
if (id == 0)
|
||||
rb_raise(rb_eSocket, "unknown socktype: %d", rai->socktype);
|
||||
socktype = rb_id2str(id);
|
||||
|
@ -1134,7 +1134,7 @@ addrinfo_mdump(VALUE self)
|
|||
if (rai->protocol == 0)
|
||||
protocol = INT2FIX(0);
|
||||
else if (IS_IP_FAMILY(afamily_int)) {
|
||||
id = intern_ipproto(rai->protocol);
|
||||
id = rsock_intern_ipproto(rai->protocol);
|
||||
if (id == 0)
|
||||
rb_raise(rb_eSocket, "unknown IP protocol: %d", rai->protocol);
|
||||
protocol = rb_id2str(id);
|
||||
|
@ -1147,7 +1147,7 @@ addrinfo_mdump(VALUE self)
|
|||
|
||||
inspectname = rai->inspectname;
|
||||
|
||||
id = intern_family(afamily_int);
|
||||
id = rsock_intern_family(afamily_int);
|
||||
if (id == 0)
|
||||
rb_raise(rb_eSocket, "unknown address family: %d", afamily_int);
|
||||
afamily = rb_id2str(id);
|
||||
|
@ -1175,7 +1175,7 @@ addrinfo_mdump(VALUE self)
|
|||
hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||
if (error) {
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf));
|
||||
break;
|
||||
|
@ -1203,12 +1203,12 @@ addrinfo_mload(VALUE self, VALUE ary)
|
|||
|
||||
v = rb_ary_entry(ary, 0);
|
||||
StringValue(v);
|
||||
if (family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &afamily) == -1)
|
||||
if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &afamily) == -1)
|
||||
rb_raise(rb_eTypeError, "unexpected address family");
|
||||
|
||||
v = rb_ary_entry(ary, 2);
|
||||
StringValue(v);
|
||||
if (family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &pfamily) == -1)
|
||||
if (rsock_family_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &pfamily) == -1)
|
||||
rb_raise(rb_eTypeError, "unexpected protocol family");
|
||||
|
||||
v = rb_ary_entry(ary, 3);
|
||||
|
@ -1216,7 +1216,7 @@ addrinfo_mload(VALUE self, VALUE ary)
|
|||
socktype = 0;
|
||||
else {
|
||||
StringValue(v);
|
||||
if (socktype_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &socktype) == -1)
|
||||
if (rsock_socktype_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &socktype) == -1)
|
||||
rb_raise(rb_eTypeError, "unexpected socktype");
|
||||
}
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ addrinfo_mload(VALUE self, VALUE ary)
|
|||
else {
|
||||
StringValue(v);
|
||||
if (IS_IP_FAMILY(afamily)) {
|
||||
if (ipproto_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &protocol) == -1)
|
||||
if (rsock_ipproto_to_int(RSTRING_PTR(v), RSTRING_LEN(v), &protocol) == -1)
|
||||
rb_raise(rb_eTypeError, "unexpected protocol");
|
||||
}
|
||||
else {
|
||||
|
@ -1519,7 +1519,7 @@ addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
|
|||
hbuf, sizeof(hbuf), pbuf, sizeof(pbuf),
|
||||
flags);
|
||||
if (error) {
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
|
||||
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
|
||||
|
@ -1857,9 +1857,9 @@ addrinfo_ipv6_to_ipv4(VALUE self)
|
|||
sin4.sin_family = AF_INET;
|
||||
SET_SIN_LEN(&sin4, sizeof(sin4));
|
||||
memcpy(&sin4.sin_addr, (char*)addr + sizeof(*addr) - sizeof(sin4.sin_addr), sizeof(sin4.sin_addr));
|
||||
return addrinfo_new((struct sockaddr *)&sin4, sizeof(sin4),
|
||||
PF_INET, rai->socktype, rai->protocol,
|
||||
rai->canonname, rai->inspectname);
|
||||
return rsock_addrinfo_new((struct sockaddr *)&sin4, sizeof(sin4),
|
||||
PF_INET, rai->socktype, rai->protocol,
|
||||
rai->canonname, rai->inspectname);
|
||||
}
|
||||
else {
|
||||
return Qnil;
|
||||
|
@ -2025,7 +2025,7 @@ addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
|
|||
if (NIL_P(vsocktype))
|
||||
socktype = SOCK_STREAM;
|
||||
else
|
||||
socktype = socktype_arg(vsocktype);
|
||||
socktype = rsock_socktype_arg(vsocktype);
|
||||
|
||||
addr = addrinfo_s_allocate(rb_cAddrinfo);
|
||||
DATA_PTR(addr) = rai = alloc_addrinfo();
|
||||
|
@ -2037,7 +2037,7 @@ addrinfo_s_unix(int argc, VALUE *argv, VALUE self)
|
|||
#endif
|
||||
|
||||
VALUE
|
||||
sockaddr_string_value(volatile VALUE *v)
|
||||
rsock_sockaddr_string_value(volatile VALUE *v)
|
||||
{
|
||||
VALUE val = *v;
|
||||
if (TYPE(val) == RUBY_T_DATA && IS_ADDRINFO(val)) {
|
||||
|
@ -2048,9 +2048,9 @@ sockaddr_string_value(volatile VALUE *v)
|
|||
}
|
||||
|
||||
char *
|
||||
sockaddr_string_value_ptr(volatile VALUE *v)
|
||||
rsock_sockaddr_string_value_ptr(volatile VALUE *v)
|
||||
{
|
||||
sockaddr_string_value(v);
|
||||
rsock_sockaddr_string_value(v);
|
||||
return RSTRING_PTR(*v);
|
||||
}
|
||||
|
||||
|
@ -2063,7 +2063,7 @@ rb_check_sockaddr_string_type(VALUE val)
|
|||
}
|
||||
|
||||
VALUE
|
||||
fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
|
||||
rsock_fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
|
||||
{
|
||||
int family;
|
||||
int socktype;
|
||||
|
@ -2078,24 +2078,24 @@ fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len)
|
|||
rb_sys_fail("getsockopt(SO_TYPE)");
|
||||
}
|
||||
|
||||
return addrinfo_new(addr, len, family, socktype, 0, Qnil, Qnil);
|
||||
return rsock_addrinfo_new(addr, len, family, socktype, 0, Qnil, Qnil);
|
||||
}
|
||||
|
||||
VALUE
|
||||
io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
|
||||
rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
|
||||
{
|
||||
rb_io_t *fptr;
|
||||
|
||||
switch (TYPE(io)) {
|
||||
case T_FIXNUM:
|
||||
return fd_socket_addrinfo(FIX2INT(io), addr, len);
|
||||
return rsock_fd_socket_addrinfo(FIX2INT(io), addr, len);
|
||||
|
||||
case T_BIGNUM:
|
||||
return fd_socket_addrinfo(NUM2INT(io), addr, len);
|
||||
return rsock_fd_socket_addrinfo(NUM2INT(io), addr, len);
|
||||
|
||||
case T_FILE:
|
||||
GetOpenFile(io, fptr);
|
||||
return fd_socket_addrinfo(fptr->fd, addr, len);
|
||||
return rsock_fd_socket_addrinfo(fptr->fd, addr, len);
|
||||
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "neither IO nor file descriptor");
|
||||
|
|
|
@ -156,7 +156,7 @@ struct sockaddr_storage {
|
|||
#define INET_SERVER 1
|
||||
#define INET_SOCKS 2
|
||||
|
||||
extern int do_not_reverse_lookup;
|
||||
extern int rsock_do_not_reverse_lookup;
|
||||
#define FMODE_NOREVLOOKUP 0x100
|
||||
|
||||
extern VALUE rb_cBasicSocket;
|
||||
|
@ -188,57 +188,57 @@ int Rconnect();
|
|||
|
||||
#define BLOCKING_REGION(func, arg) (long)rb_thread_blocking_region((func), (arg), RUBY_UBF_IO, 0)
|
||||
|
||||
#define SockAddrStringValue(v) sockaddr_string_value(&(v))
|
||||
#define SockAddrStringValuePtr(v) sockaddr_string_value_ptr(&(v))
|
||||
VALUE sockaddr_string_value(volatile VALUE *);
|
||||
char *sockaddr_string_value_ptr(volatile VALUE *);
|
||||
#define SockAddrStringValue(v) rsock_sockaddr_string_value(&(v))
|
||||
#define SockAddrStringValuePtr(v) rsock_sockaddr_string_value_ptr(&(v))
|
||||
VALUE rsock_sockaddr_string_value(volatile VALUE *);
|
||||
char *rsock_sockaddr_string_value_ptr(volatile VALUE *);
|
||||
VALUE rb_check_sockaddr_string_type(VALUE);
|
||||
|
||||
NORETURN(void raise_socket_error(const char *, int));
|
||||
NORETURN(void rsock_raise_socket_error(const char *, int));
|
||||
|
||||
int family_arg(VALUE domain);
|
||||
int socktype_arg(VALUE type);
|
||||
int level_arg(int family, VALUE level);
|
||||
int optname_arg(int family, int level, VALUE optname);
|
||||
int cmsg_type_arg(int family, int level, VALUE type);
|
||||
int shutdown_how_arg(VALUE how);
|
||||
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 rb_sock_getfamily(int sockfd);
|
||||
|
||||
int rb_getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
|
||||
int rb_getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
|
||||
struct addrinfo *sock_addrinfo(VALUE host, VALUE port, int socktype, int flags);
|
||||
struct addrinfo* sock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_hack);
|
||||
VALUE fd_socket_addrinfo(int fd, struct sockaddr *addr, socklen_t len);
|
||||
VALUE io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len);
|
||||
struct addrinfo *sock_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 addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
|
||||
VALUE rsock_addrinfo_new(struct sockaddr *addr, socklen_t len, int family, int socktype, int protocol, VALUE canonname, VALUE inspectname);
|
||||
|
||||
VALUE make_ipaddr(struct sockaddr *addr);
|
||||
VALUE ipaddr(struct sockaddr *sockaddr, int norevlookup);
|
||||
VALUE make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t));
|
||||
VALUE rsock_make_ipaddr(struct sockaddr *addr);
|
||||
VALUE rsock_ipaddr(struct sockaddr *sockaddr, int norevlookup);
|
||||
VALUE rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(struct sockaddr *, size_t));
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
const char* unixpath(struct sockaddr_un *sockaddr, socklen_t len);
|
||||
VALUE unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
|
||||
const char* rsock_unixpath(struct sockaddr_un *sockaddr, socklen_t len);
|
||||
VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len);
|
||||
#endif
|
||||
|
||||
int ruby_socket(int domain, int type, int proto);
|
||||
VALUE init_sock(VALUE sock, int fd);
|
||||
VALUE rsock_init_sock(VALUE sock, int fd);
|
||||
VALUE sock_s_socketpair(int argc, VALUE *argv, VALUE klass);
|
||||
VALUE init_inetsock(VALUE sock, VALUE remote_host, VALUE remote_serv, VALUE local_host, VALUE local_serv, int type);
|
||||
VALUE init_unixsock(VALUE sock, VALUE path, int server);
|
||||
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);
|
||||
|
||||
struct send_arg {
|
||||
struct rsock_send_arg {
|
||||
int fd, flags;
|
||||
VALUE mesg;
|
||||
struct sockaddr *to;
|
||||
socklen_t tolen;
|
||||
};
|
||||
|
||||
VALUE sendto_blocking(void *data);
|
||||
VALUE send_blocking(void *data);
|
||||
VALUE bsock_send(int argc, VALUE *argv, VALUE sock);
|
||||
VALUE rsock_sendto_blocking(void *data);
|
||||
VALUE rsock_send_blocking(void *data);
|
||||
VALUE rsock_bsock_send(int argc, VALUE *argv, VALUE sock);
|
||||
|
||||
enum sock_recv_type {
|
||||
RECV_RECV, /* BasicSocket#recv(no from) */
|
||||
|
@ -247,17 +247,17 @@ enum sock_recv_type {
|
|||
RECV_SOCKET /* Socket#recvfrom */
|
||||
};
|
||||
|
||||
VALUE s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
|
||||
VALUE s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
|
||||
VALUE rsock_s_recvfrom_nonblock(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
|
||||
VALUE rsock_s_recvfrom(VALUE sock, int argc, VALUE *argv, enum sock_recv_type from);
|
||||
|
||||
int ruby_connect(int fd, const struct sockaddr *sockaddr, int len, int socks);
|
||||
|
||||
VALUE sock_listen(VALUE sock, VALUE log);
|
||||
|
||||
VALUE s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
|
||||
VALUE s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len);
|
||||
VALUE rsock_s_accept(VALUE klass, int fd, struct sockaddr *sockaddr, socklen_t *len);
|
||||
VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len);
|
||||
|
||||
VALUE sockopt_new(int family, int level, int optname, VALUE data);
|
||||
VALUE rsock_sockopt_new(int family, int level, int optname, VALUE data);
|
||||
|
||||
#ifdef HAVE_ST_MSG_CONTROL
|
||||
void rsock_discard_cmsg_resource(struct msghdr *mh);
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
static void
|
||||
setup_domain_and_type(VALUE domain, int *dv, VALUE type, int *tv)
|
||||
{
|
||||
*dv = family_arg(domain);
|
||||
*tv = socktype_arg(type);
|
||||
*dv = rsock_family_arg(domain);
|
||||
*tv = rsock_socktype_arg(type);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,7 +52,7 @@ sock_initialize(int argc, VALUE *argv, VALUE sock)
|
|||
fd = ruby_socket(d, t, NUM2INT(protocol));
|
||||
if (fd < 0) rb_sys_fail("socket(2)");
|
||||
|
||||
return init_sock(sock, fd);
|
||||
return rsock_init_sock(sock, fd);
|
||||
}
|
||||
|
||||
#if defined HAVE_SOCKETPAIR
|
||||
|
@ -120,8 +120,8 @@ sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
|
|||
rb_sys_fail("socketpair(2)");
|
||||
}
|
||||
|
||||
s1 = init_sock(rb_obj_alloc(klass), sp[0]);
|
||||
s2 = init_sock(rb_obj_alloc(klass), sp[1]);
|
||||
s1 = rsock_init_sock(rb_obj_alloc(klass), sp[0]);
|
||||
s2 = rsock_init_sock(rb_obj_alloc(klass), sp[1]);
|
||||
r = rb_assoc_new(s1, s2);
|
||||
if (rb_block_given_p()) {
|
||||
return rb_ensure(pair_yield, r, io_close, s1);
|
||||
|
@ -604,7 +604,7 @@ sock_listen(VALUE sock, VALUE log)
|
|||
static VALUE
|
||||
sock_recvfrom(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom(sock, argc, argv, RECV_SOCKET);
|
||||
return rsock_s_recvfrom(sock, argc, argv, RECV_SOCKET);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -668,7 +668,7 @@ sock_recvfrom(int argc, VALUE *argv, VALUE sock)
|
|||
static VALUE
|
||||
sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom_nonblock(sock, argc, argv, RECV_SOCKET);
|
||||
return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_SOCKET);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -694,9 +694,9 @@ sock_accept(VALUE sock)
|
|||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
sock2 = rsock_s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -756,8 +756,8 @@ sock_accept_nonblock(VALUE sock)
|
|||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)&buf, &len);
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
sock2 = rsock_s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)&buf, &len);
|
||||
return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -808,9 +808,9 @@ sock_sysaccept(VALUE sock)
|
|||
socklen_t len = sizeof buf;
|
||||
|
||||
GetOpenFile(sock, fptr);
|
||||
sock2 = s_accept(0,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
sock2 = rsock_s_accept(0,fptr->fd,(struct sockaddr*)&buf,&len);
|
||||
|
||||
return rb_assoc_new(sock2, io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
return rb_assoc_new(sock2, rsock_io_socket_addrinfo(sock2, (struct sockaddr*)&buf, len));
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETHOSTNAME
|
||||
|
@ -874,7 +874,7 @@ make_addrinfo(struct addrinfo *res0)
|
|||
}
|
||||
base = rb_ary_new();
|
||||
for (res = res0; res; res = res->ai_next) {
|
||||
ary = ipaddr(res->ai_addr, do_not_reverse_lookup);
|
||||
ary = rsock_ipaddr(res->ai_addr, rsock_do_not_reverse_lookup);
|
||||
if (res->ai_canonname) {
|
||||
RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
|
||||
}
|
||||
|
@ -922,7 +922,7 @@ static VALUE
|
|||
sock_s_gethostbyname(VALUE obj, VALUE host)
|
||||
{
|
||||
rb_secure(3);
|
||||
return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr);
|
||||
return rsock_make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME), sock_sockaddr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -947,7 +947,7 @@ sock_s_gethostbyaddr(int argc, VALUE *argv)
|
|||
rb_scan_args(argc, argv, "11", &addr, &family);
|
||||
sa = (struct sockaddr*)StringValuePtr(addr);
|
||||
if (!NIL_P(family)) {
|
||||
t = family_arg(family);
|
||||
t = rsock_family_arg(family);
|
||||
}
|
||||
#ifdef INET6
|
||||
else if (RSTRING_LEN(addr) == 16) {
|
||||
|
@ -1094,10 +1094,10 @@ sock_s_getaddrinfo(int argc, VALUE *argv)
|
|||
rb_scan_args(argc, argv, "24", &host, &port, &family, &socktype, &protocol, &flags);
|
||||
|
||||
MEMZERO(&hints, struct addrinfo, 1);
|
||||
hints.ai_family = NIL_P(family) ? PF_UNSPEC : family_arg(family);
|
||||
hints.ai_family = NIL_P(family) ? PF_UNSPEC : rsock_family_arg(family);
|
||||
|
||||
if (!NIL_P(socktype)) {
|
||||
hints.ai_socktype = socktype_arg(socktype);
|
||||
hints.ai_socktype = rsock_socktype_arg(socktype);
|
||||
}
|
||||
if (!NIL_P(protocol)) {
|
||||
hints.ai_protocol = NUM2INT(protocol);
|
||||
|
@ -1182,7 +1182,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
else {
|
||||
/*
|
||||
* 4th element holds numeric form, don't resolve.
|
||||
* see ipaddr().
|
||||
* see rsock_ipaddr().
|
||||
*/
|
||||
#ifdef AI_NUMERICHOST /* AIX 4.3.3 doesn't have AI_NUMERICHOST. */
|
||||
hints.ai_flags |= AI_NUMERICHOST;
|
||||
|
@ -1218,7 +1218,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
}
|
||||
hints.ai_socktype = (fl & NI_DGRAM) ? SOCK_DGRAM : SOCK_STREAM;
|
||||
/* af */
|
||||
hints.ai_family = NIL_P(af) ? PF_UNSPEC : family_arg(af);
|
||||
hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af);
|
||||
error = rb_getaddrinfo(hptr, pptr, &hints, &res);
|
||||
if (error) goto error_exit_addr;
|
||||
sap = res->ai_addr;
|
||||
|
@ -1250,11 +1250,11 @@ sock_s_getnameinfo(int argc, VALUE *argv)
|
|||
|
||||
error_exit_addr:
|
||||
if (res) freeaddrinfo(res);
|
||||
raise_socket_error("getaddrinfo", error);
|
||||
rsock_raise_socket_error("getaddrinfo", error);
|
||||
|
||||
error_exit_name:
|
||||
if (res) freeaddrinfo(res);
|
||||
raise_socket_error("getnameinfo", error);
|
||||
rsock_raise_socket_error("getnameinfo", error);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1320,7 +1320,7 @@ sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
|
|||
rb_raise(rb_eArgError, "not an AF_INET sockaddr");
|
||||
#endif
|
||||
}
|
||||
host = make_ipaddr((struct sockaddr*)sockaddr);
|
||||
host = rsock_make_ipaddr((struct sockaddr*)sockaddr);
|
||||
OBJ_INFECT(host, addr);
|
||||
return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
|
||||
}
|
||||
|
@ -1390,7 +1390,7 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
|
|||
rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
|
||||
RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un));
|
||||
}
|
||||
sun_path = unixpath(sockaddr, RSTRING_LEN(addr));
|
||||
sun_path = rsock_unixpath(sockaddr, RSTRING_LEN(addr));
|
||||
if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) &&
|
||||
sun_path == sockaddr->sun_path &&
|
||||
sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) {
|
||||
|
@ -1454,7 +1454,7 @@ sockaddr_obj(struct sockaddr *addr)
|
|||
len = SA_LEN(addr);
|
||||
#endif
|
||||
|
||||
return addrinfo_new(addr, len, addr->sa_family, 0, 0, Qnil, Qnil);
|
||||
return rsock_addrinfo_new(addr, len, addr->sa_family, 0, 0, Qnil, Qnil);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ socks_init(VALUE sock, VALUE host, VALUE serv)
|
|||
init = 1;
|
||||
}
|
||||
|
||||
return init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
|
||||
return rsock_init_inetsock(sock, host, serv, Qnil, Qnil, INET_SOCKS);
|
||||
}
|
||||
|
||||
#ifdef SOCKS5
|
||||
|
|
|
@ -29,7 +29,7 @@ tcp_svr_init(int argc, VALUE *argv, VALUE sock)
|
|||
VALUE hostname, port;
|
||||
|
||||
rb_scan_args(argc, argv, "011", &hostname, &port);
|
||||
return init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER);
|
||||
return rsock_init_inetsock(sock, hostname, port, Qnil, Qnil, INET_SERVER);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -52,8 +52,8 @@ tcp_accept(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(from);
|
||||
return s_accept(rb_cTCPSocket, fptr->fd,
|
||||
(struct sockaddr*)&from, &fromlen);
|
||||
return rsock_s_accept(rb_cTCPSocket, fptr->fd,
|
||||
(struct sockaddr*)&from, &fromlen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -94,8 +94,8 @@ tcp_accept_nonblock(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(from);
|
||||
return s_accept_nonblock(rb_cTCPSocket, fptr,
|
||||
(struct sockaddr *)&from, &fromlen);
|
||||
return rsock_s_accept_nonblock(rb_cTCPSocket, fptr,
|
||||
(struct sockaddr *)&from, &fromlen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -121,7 +121,7 @@ tcp_sysaccept(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(from);
|
||||
return s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
|
||||
return rsock_s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,14 +27,14 @@ tcp_init(int argc, VALUE *argv, VALUE sock)
|
|||
rb_scan_args(argc, argv, "22", &remote_host, &remote_serv,
|
||||
&local_host, &local_serv);
|
||||
|
||||
return init_inetsock(sock, remote_host, remote_serv,
|
||||
local_host, local_serv, INET_CLIENT);
|
||||
return rsock_init_inetsock(sock, remote_host, remote_serv,
|
||||
local_host, local_serv, INET_CLIENT);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
tcp_sockaddr(struct sockaddr *addr, size_t len)
|
||||
{
|
||||
return make_ipaddr(addr);
|
||||
return rsock_make_ipaddr(addr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -51,7 +51,7 @@ static VALUE
|
|||
tcp_s_gethostbyname(VALUE obj, VALUE host)
|
||||
{
|
||||
rb_secure(3);
|
||||
return make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME),
|
||||
return rsock_make_hostent(host, sock_addrinfo(host, Qnil, SOCK_STREAM, AI_CANONNAME),
|
||||
tcp_sockaddr);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ udp_init(int argc, VALUE *argv, VALUE sock)
|
|||
|
||||
rb_secure(3);
|
||||
if (rb_scan_args(argc, argv, "01", &arg) == 1) {
|
||||
family = family_arg(arg);
|
||||
family = rsock_family_arg(arg);
|
||||
}
|
||||
fd = ruby_socket(family, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
rb_sys_fail("socket(2) - udp");
|
||||
}
|
||||
|
||||
return init_sock(sock, fd);
|
||||
return rsock_init_sock(sock, fd);
|
||||
}
|
||||
|
||||
struct udp_arg
|
||||
|
@ -157,10 +157,10 @@ udp_send(int argc, VALUE *argv, VALUE sock)
|
|||
rb_io_t *fptr;
|
||||
int n;
|
||||
struct addrinfo *res0, *res;
|
||||
struct send_arg arg;
|
||||
struct rsock_send_arg arg;
|
||||
|
||||
if (argc == 2 || argc == 3) {
|
||||
return bsock_send(argc, argv, sock);
|
||||
return rsock_bsock_send(argc, argv, sock);
|
||||
}
|
||||
rb_secure(4);
|
||||
rb_scan_args(argc, argv, "4", &arg.mesg, &flags, &host, &port);
|
||||
|
@ -175,7 +175,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
|
|||
arg.to = res->ai_addr;
|
||||
arg.tolen = res->ai_addrlen;
|
||||
rb_thread_fd_writable(arg.fd);
|
||||
n = (int)BLOCKING_REGION(sendto_blocking, &arg);
|
||||
n = (int)BLOCKING_REGION(rsock_sendto_blocking, &arg);
|
||||
if (n >= 0) {
|
||||
freeaddrinfo(res0);
|
||||
return INT2FIX(n);
|
||||
|
@ -233,7 +233,7 @@ udp_send(int argc, VALUE *argv, VALUE sock)
|
|||
static VALUE
|
||||
udp_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom_nonblock(sock, argc, argv, RECV_IP);
|
||||
return rsock_s_recvfrom_nonblock(sock, argc, argv, RECV_IP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
static VALUE
|
||||
unix_svr_init(VALUE sock, VALUE path)
|
||||
{
|
||||
return init_unixsock(sock, path, 1);
|
||||
return rsock_init_unixsock(sock, path, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -53,8 +53,8 @@ unix_accept(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(struct sockaddr_un);
|
||||
return s_accept(rb_cUNIXSocket, fptr->fd,
|
||||
(struct sockaddr*)&from, &fromlen);
|
||||
return rsock_s_accept(rb_cUNIXSocket, fptr->fd,
|
||||
(struct sockaddr*)&from, &fromlen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -95,8 +95,8 @@ unix_accept_nonblock(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(from);
|
||||
return s_accept_nonblock(rb_cUNIXSocket, fptr,
|
||||
(struct sockaddr *)&from, &fromlen);
|
||||
return rsock_s_accept_nonblock(rb_cUNIXSocket, fptr,
|
||||
(struct sockaddr *)&from, &fromlen);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -126,7 +126,7 @@ unix_sysaccept(VALUE sock)
|
|||
|
||||
GetOpenFile(sock, fptr);
|
||||
fromlen = sizeof(struct sockaddr_un);
|
||||
return s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
|
||||
return rsock_s_accept(0, fptr->fd, (struct sockaddr*)&from, &fromlen);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,7 @@ unixsock_connect_internal(struct unixsock_arg *arg)
|
|||
}
|
||||
|
||||
VALUE
|
||||
init_unixsock(VALUE sock, VALUE path, int server)
|
||||
rsock_init_unixsock(VALUE sock, VALUE path, int server)
|
||||
{
|
||||
struct sockaddr_un sockaddr;
|
||||
int fd, status;
|
||||
|
@ -67,7 +67,7 @@ init_unixsock(VALUE sock, VALUE path, int server)
|
|||
|
||||
if (server) listen(fd, 5);
|
||||
|
||||
init_sock(sock, fd);
|
||||
rsock_init_sock(sock, fd);
|
||||
if (server) {
|
||||
GetOpenFile(sock, fptr);
|
||||
fptr->pathv = rb_str_new_frozen(path);
|
||||
|
@ -89,7 +89,7 @@ init_unixsock(VALUE sock, VALUE path, int server)
|
|||
static VALUE
|
||||
unix_init(VALUE sock, VALUE path)
|
||||
{
|
||||
return init_unixsock(sock, path, 0);
|
||||
return rsock_init_unixsock(sock, path, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -113,7 +113,7 @@ unix_path(VALUE sock)
|
|||
socklen_t len = sizeof(addr);
|
||||
if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
|
||||
rb_sys_fail(0);
|
||||
fptr->pathv = rb_obj_freeze(rb_str_new_cstr(unixpath(&addr, len)));
|
||||
fptr->pathv = rb_obj_freeze(rb_str_new_cstr(rsock_unixpath(&addr, len)));
|
||||
}
|
||||
return rb_str_dup(fptr->pathv);
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ unix_path(VALUE sock)
|
|||
static VALUE
|
||||
unix_recvfrom(int argc, VALUE *argv, VALUE sock)
|
||||
{
|
||||
return s_recvfrom(sock, argc, argv, RECV_UNIX);
|
||||
return rsock_s_recvfrom(sock, argc, argv, RECV_UNIX);
|
||||
}
|
||||
|
||||
#if defined(HAVE_ST_MSG_CONTROL) && defined(SCM_RIGHTS)
|
||||
|
@ -418,7 +418,7 @@ unix_addr(VALUE sock)
|
|||
|
||||
if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
|
||||
rb_sys_fail("getsockname(2)");
|
||||
return unixaddr(&addr, len);
|
||||
return rsock_unixaddr(&addr, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -444,7 +444,7 @@ unix_peeraddr(VALUE sock)
|
|||
|
||||
if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0)
|
||||
rb_sys_fail("getpeername(2)");
|
||||
return unixaddr(&addr, len);
|
||||
return rsock_unixaddr(&addr, len);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Reference in a new issue