diff options
| author | Tomoyuki Sahara <[email protected]> | 2014-12-26 16:00:50 +0900 |
|---|---|---|
| committer | Tomoyuki Sahara <[email protected]> | 2014-12-26 16:00:50 +0900 |
| commit | 0d05a22602a49bdaba3f304ec6eb0808f1e6c286 (patch) | |
| tree | 3763fdc3b25dd6fc73cc241bcf58832f96344736 /mrblib | |
| parent | 7b17158f88a64c97c34cd4b617bb9a0185e5fb43 (diff) | |
| download | mruby-0d05a22602a49bdaba3f304ec6eb0808f1e6c286.tar.gz mruby-0d05a22602a49bdaba3f304ec6eb0808f1e6c286.zip | |
don't call undefined method. fixes #15.
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/socket.rb | 7 |
1 files changed, 4 insertions, 3 deletions
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) |
