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