summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index dfd65a2672..e62837891b 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -683,6 +683,23 @@ sock_addrinfo(host, port, socktype, flags)
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;
}