summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 16:20:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-04 16:20:05 +0000
commit5ce10c1359be7f7278491a736be95ce4b50116ae (patch)
treebfe08bf5bef26724a0682bde799efc0bba18cab9 /ext/socket/socket.c
parent1934c7a80b21c281552011801029c871f5b04120 (diff)
* ext/socket/socket.c (sock_s_socketpair): make 3rd argument optional.
* ext/socket/unixsocket.c (unix_s_socketpair): follow the above change. * ext/socket/rubysocket.h (sock_s_socketpair): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index db27a1154b..a85128cd47 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -97,13 +97,18 @@ pair_yield(VALUE pair)
*
*/
VALUE
-sock_s_socketpair(VALUE klass, VALUE domain, VALUE type, VALUE protocol)
+sock_s_socketpair(int argc, VALUE *argv, VALUE klass)
{
#if defined HAVE_SOCKETPAIR
+ VALUE domain, type, protocol;
int d, t, p, sp[2];
int ret;
VALUE s1, s2, r;
+ rb_scan_args(argc, argv, "21", &domain, &type, &protocol);
+ if (NIL_P(protocol))
+ protocol = INT2FIX(0);
+
setup_domain_and_type(domain, &d, type, &t);
p = NUM2INT(protocol);
ret = socketpair(d, t, p, sp);
@@ -1760,8 +1765,8 @@ Init_socket()
rb_define_method(rb_cSocket, "recvfrom", sock_recvfrom, -1);
rb_define_method(rb_cSocket, "recvfrom_nonblock", sock_recvfrom_nonblock, -1);
- rb_define_singleton_method(rb_cSocket, "socketpair", sock_s_socketpair, 3);
- rb_define_singleton_method(rb_cSocket, "pair", sock_s_socketpair, 3);
+ rb_define_singleton_method(rb_cSocket, "socketpair", sock_s_socketpair, -1);
+ rb_define_singleton_method(rb_cSocket, "pair", sock_s_socketpair, -1);
rb_define_singleton_method(rb_cSocket, "gethostname", sock_gethostname, 0);
rb_define_singleton_method(rb_cSocket, "gethostbyname", sock_s_gethostbyname, 1);
rb_define_singleton_method(rb_cSocket, "gethostbyaddr", sock_s_gethostbyaddr, -1);