summaryrefslogtreecommitdiff
path: root/lang/ruby18/patches/patch-af
blob: 617fead07f7a3360ec5a3ee6cd7e17e5a27a1d10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$NetBSD: patch-af,v 1.1.1.1 2004/11/27 14:11:15 taca Exp $

--- ext/socket/socket.c.orig	2003-12-16 00:54:07.000000000 +0900
+++ ext/socket/socket.c
@@ -650,6 +650,23 @@ sock_addrinfo(host, port, socktype, flag
 	rb_raise(rb_eSocket, "getaddrinfo: %s", gai_strerror(error));
     }
 
+#if defined(__APPLE__) && defined(__MACH__)
+    {
+       struct addrinfo *r;
+       r = res;
+       while (r) {
+	    if (! r->ai_socktype) r->ai_socktype = hints.ai_socktype;
+	    if (! r->ai_protocol) {
+		if (r->ai_socktype == SOCK_DGRAM) {
+		    r->ai_protocol = IPPROTO_UDP;
+		} else if (r->ai_socktype == SOCK_STREAM) {
+		    r->ai_protocol = IPPROTO_TCP;
+		}
+	    }
+	    r = r->ai_next;
+       }
+    }
+#endif
     return res;
 }