Last change
on this file since 439 was 439, checked in by coas-nagasima, 4 years ago |
mrubyを2.1.1に更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-ruby;charset=UTF-8
|
File size:
920 bytes
|
Rev | Line | |
---|
[439] | 1 | unless SocketTest.win?
|
---|
| 2 |
|
---|
| 3 | # Note: most of tests below will fail if UDPSocket is broken.
|
---|
| 4 |
|
---|
| 5 | assert('IPSocket.getaddress') do
|
---|
| 6 | l = IPSocket.getaddress("localhost")
|
---|
| 7 | assert_true (l == "127.0.0.1" or l == "::1")
|
---|
| 8 | end
|
---|
| 9 |
|
---|
| 10 | assert('IPSocket.addr') do
|
---|
| 11 | localhost = "127.0.0.1"
|
---|
| 12 | s = UDPSocket.new
|
---|
| 13 | s.bind(localhost, 0)
|
---|
| 14 | port = Addrinfo.new(s.getsockname).ip_port
|
---|
| 15 |
|
---|
| 16 | a = s.addr
|
---|
| 17 | assert_equal "AF_INET", a[0]
|
---|
| 18 | assert_equal port, a[1]
|
---|
| 19 | assert_equal localhost, a[2]
|
---|
| 20 | assert_equal localhost, a[3]
|
---|
| 21 | s.close
|
---|
| 22 | true
|
---|
| 23 | end
|
---|
| 24 |
|
---|
| 25 | assert('IPSocket.peeraddr') do
|
---|
| 26 | localhost = "127.0.0.1"
|
---|
| 27 | server = UDPSocket.new
|
---|
| 28 | server.bind(localhost, 0)
|
---|
| 29 | port = server.local_address.ip_port
|
---|
| 30 |
|
---|
| 31 | client = UDPSocket.new
|
---|
| 32 | client.connect(localhost, port)
|
---|
| 33 |
|
---|
| 34 | a = client.peeraddr
|
---|
| 35 | assert_equal "AF_INET", a[0]
|
---|
| 36 | assert_equal port, a[1]
|
---|
| 37 | assert_equal localhost, a[2]
|
---|
| 38 | assert_equal localhost, a[3]
|
---|
| 39 | client.close
|
---|
| 40 | server.close
|
---|
| 41 | true
|
---|
| 42 | end
|
---|
| 43 |
|
---|
| 44 | end # win?
|
---|
Note:
See
TracBrowser
for help on using the repository browser.