Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0d05a226
Commit
0d05a226
authored
Dec 26, 2014
by
Tomoyuki Sahara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't call undefined method. fixes #15.
parent
7b17158f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
3 deletions
+21
-3
mrblib/socket.rb
mrblib/socket.rb
+4
-3
test/socket.rb
test/socket.rb
+17
-0
No files found.
mrblib/socket.rb
View file @
0d05a226
...
@@ -63,9 +63,9 @@ class Addrinfo
...
@@ -63,9 +63,9 @@ class Addrinfo
def
inspect
def
inspect
if
ipv4?
or
ipv6?
if
ipv4?
or
ipv6?
if
@protocol
==
Socket
::
IPPROTO_TCP
if
@protocol
==
Socket
::
IPPROTO_TCP
or
(
@socktype
==
Socket
::
SOCK_STREAM
and
@protocol
==
0
)
proto
=
'TCP'
proto
=
'TCP'
elsif
@protocol
==
Socket
::
IPPROTO_UDP
elsif
@protocol
==
Socket
::
IPPROTO_UDP
or
(
@socktype
==
Socket
::
SOCK_DGRAM
and
@protocol
==
0
)
proto
=
'UDP'
proto
=
'UDP'
else
else
proto
=
'???'
proto
=
'???'
...
@@ -439,7 +439,8 @@ class Socket
...
@@ -439,7 +439,8 @@ class Socket
def
recvfrom
(
maxlen
,
flags
=
0
)
def
recvfrom
(
maxlen
,
flags
=
0
)
msg
,
sa
=
_recvfrom
(
maxlen
,
flags
)
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
end
def
recvfrom_nonblock
(
*
args
)
def
recvfrom_nonblock
(
*
args
)
...
...
test/socket.rb
View file @
0d05a226
...
@@ -15,3 +15,20 @@ assert('Socket::getaddrinfo') do
...
@@ -15,3 +15,20 @@ assert('Socket::getaddrinfo') do
assert_equal
Socket
::
SOCK_DGRAM
,
a
[
5
]
assert_equal
Socket
::
SOCK_DGRAM
,
a
[
5
]
assert_equal
Socket
::
IPPROTO_UDP
,
a
[
6
]
assert_equal
Socket
::
IPPROTO_UDP
,
a
[
6
]
end
end
assert
(
'Socket#recvfrom'
)
do
begin
sstr
=
"abcdefg"
s
=
Socket
.
new
(
Socket
::
AF_INET
,
Socket
::
SOCK_DGRAM
,
0
)
c
=
Socket
.
new
(
Socket
::
AF_INET
,
Socket
::
SOCK_DGRAM
,
0
)
s
.
bind
(
Socket
.
sockaddr_in
(
0
,
"127.0.0.1"
))
c
.
send
sstr
,
0
,
s
.
getsockname
rstr
,
ai
=
s
.
recvfrom
sstr
.
size
assert_equal
sstr
,
rstr
assert_true
"127.0.0.1"
,
ai
.
ip_address
ensure
s
.
close
rescue
nil
c
.
close
rescue
nil
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment