summaryrefslogtreecommitdiff
path: root/lang/ruby16-base/patches/patch-af
blob: 4107316485160fea7c229e7df3714455ff03469f (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 2005/03/06 16:36:08 taca Exp $

--- ext/socket/socket.c.orig	2002-11-01 03:40:11.000000000 +0900
+++ ext/socket/socket.c
@@ -585,6 +585,23 @@ ip_addrsetup(host, port)
 	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;
 }