summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/extconf.rb6
-rw-r--r--ext/socket/socket.c8
2 files changed, 8 insertions, 6 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index f72ac2ba42..45e596700c 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -194,8 +194,10 @@ end
have_header("netinet/tcp.h") if not /cygwin/ =~ RUBY_PLATFORM # for cygwin 1.1.5
have_header("netinet/udp.h")
-have_struct_member('struct msghdr', 'msg_control', header=['sys/types.h', 'sys/socket.h'])
-have_struct_member('struct msghdr', 'msg_accrights', header=['sys/types.h', 'sys/socket.h'])
+if have_func("sendmsg") or have_func("recvmsg")
+ have_struct_member('struct msghdr', 'msg_control', header=['sys/types.h', 'sys/socket.h'])
+ have_struct_member('struct msghdr', 'msg_accrights', header=['sys/types.h', 'sys/socket.h'])
+end
$getaddr_info_ok = false
if !enable_config("wide-getaddrinfo", false) and try_run(<<EOF)
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 5c78901772..590d2c31b3 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1508,7 +1508,7 @@ static VALUE
unix_send_io(sock, val)
VALUE sock, val;
{
-#if defined(HAVE_ST_MSG_CONTROL) || defined(HAVE_ST_MSG_ACCRIGHTS)
+#if defined(HAVE_SENDMSG) && (defined(HAVE_ST_MSG_CONTROL) || defined(HAVE_ST_MSG_ACCRIGHTS))
int fd;
OpenFile *fptr;
struct msghdr msg;
@@ -1574,7 +1574,7 @@ unix_recv_io(argc, argv, sock)
VALUE *argv;
VALUE sock;
{
-#if defined(HAVE_ST_MSG_CONTROL) || defined(HAVE_ST_MSG_ACCRIGHTS)
+#if defined(HAVE_RECVMSG) && (defined(HAVE_ST_MSG_CONTROL) || defined(HAVE_ST_MSG_ACCRIGHTS))
VALUE klass, mode;
OpenFile *fptr;
struct msghdr msg;
@@ -1817,7 +1817,7 @@ setup_domain_and_type(domain, dv, type, tv)
}
static VALUE
-sock_init(sock, domain, type, protocol)
+sock_initialize(sock, domain, type, protocol)
VALUE sock, domain, type, protocol;
{
int fd;
@@ -2483,7 +2483,7 @@ Init_socket()
rb_cSocket = rb_define_class("Socket", rb_cBasicSocket);
- rb_define_method(rb_cSocket, "initialize", sock_init, 3);
+ rb_define_method(rb_cSocket, "initialize", sock_initialize, 3);
rb_define_method(rb_cSocket, "connect", sock_connect, 1);
rb_define_method(rb_cSocket, "bind", sock_bind, 1);
rb_define_method(rb_cSocket, "listen", sock_listen, 1);