From 0d05a22602a49bdaba3f304ec6eb0808f1e6c286 Mon Sep 17 00:00:00 2001 From: Tomoyuki Sahara Date: Fri, 26 Dec 2014 16:00:50 +0900 Subject: don't call undefined method. fixes #15. --- mrblib/socket.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mrblib') diff --git a/mrblib/socket.rb b/mrblib/socket.rb index e3a1487d4..2ff144080 100644 --- a/mrblib/socket.rb +++ b/mrblib/socket.rb @@ -63,9 +63,9 @@ class Addrinfo def inspect if ipv4? or ipv6? - if @protocol == Socket::IPPROTO_TCP + if @protocol == Socket::IPPROTO_TCP or (@socktype == Socket::SOCK_STREAM and @protocol == 0) proto = 'TCP' - elsif @protocol == Socket::IPPROTO_UDP + elsif @protocol == Socket::IPPROTO_UDP or (@socktype == Socket::SOCK_DGRAM and @protocol == 0) proto = 'UDP' else proto = '???' @@ -439,7 +439,8 @@ class Socket def recvfrom(maxlen, flags=0) msg, sa = _recvfrom(maxlen, flags) - [ msg, _ai_to_array(Addrinfo.new(sa)) ] + socktype = self.getsockopt(Socket::SOL_SOCKET, Socket::SO_TYPE).int + [ msg, Addrinfo.new(sa, Socket::PF_UNSPEC, socktype) ] end def recvfrom_nonblock(*args) -- cgit v1.2.3