diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-06 02:39:44 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-04-06 02:39:44 +0000 |
commit | d933fb2296e4ace25c5eb558be56cd23a8fcc88f (patch) | |
tree | 597f59b7faf29ed9e5b83692495338a3cb7576fe /test/socket/test_tcp.rb | |
parent | e4283fd39d9e8c508ce5ee2dc069b6f5545cd3d8 (diff) | |
download | ruby-d933fb2296e4ace25c5eb558be56cd23a8fcc88f.tar.gz |
* ext/socket: Improve socket exception message to show socket address.
[ruby-core:45617] [Feature #6583] proposed Eric Hodel.
* ext/socket/rubysocket.h (rsock_sys_fail_host_port): Declared.
(rsock_sys_fail_path): Ditto.
(rsock_sys_fail_sockaddr): Ditto.
* ext/socket/udpsocket.c (udp_connect): Use rsock_sys_fail_host_port.
(udp_bind): Ditto.
(udp_send): Ditto.
* ext/socket/init.c (rsock_init_sock): Specify a string for rb_sys_fail
argument.
(make_fd_nonblock): Ditto.
(rsock_s_accept): Ditto.
* ext/socket/ipsocket.c (init_inetsock_internal): Use
rsock_sys_fail_host_port.
* ext/socket/socket.c (rsock_sys_fail_host_port): Defined.
(rsock_sys_fail_path): Ditto.
(rsock_sys_fail_sockaddr): Ditto.
(setup_domain_and_type): Use rsock_sys_fail_sockaddr.
(sock_connect_nonblock): Ditto.
(sock_bind): Ditto.
(sock_gethostname): Specify a string for rb_sys_fail argument.
(socket_s_ip_address_list): Ditto.
* ext/socket/basicsocket.c (bsock_shutdown): Specify a string for
rb_sys_fail argument.
(bsock_setsockopt): Use rsock_sys_fail_path.
(bsock_getsockopt): Ditto.
(bsock_getpeereid): Refine the argument for rb_sys_fail.
* ext/socket/unixsocket.c (rsock_init_unixsock): Use
rsock_sys_fail_path.
(unix_path): Ditto.
(unix_send_io): Ditto.
(unix_recv_io): Ditto.
(unix_addr): Ditto.
(unix_peeraddr): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket/test_tcp.rb')
-rw-r--r-- | test/socket/test_tcp.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/socket/test_tcp.rb b/test/socket/test_tcp.rb index 2634e20651..3cf1e3c36d 100644 --- a/test/socket/test_tcp.rb +++ b/test/socket/test_tcp.rb @@ -6,6 +6,23 @@ end class TestSocket_TCPSocket < Test::Unit::TestCase + def test_initialize_failure + s = TCPServer.new("localhost", nil) + server_port = s.addr[1] + + c = TCPSocket.new("localhost", server_port) + client_port = c.addr[1] + + begin + # TCPServer.new uses SO_REUSEADDR so we must create a failure on the + # local address. + TCPSocket.new("localhost", server_port, "localhost", client_port) + flunk "expected SystemCallError" + rescue SystemCallError => e + assert_match "for \"localhost\" port #{client_port}", e.message + end + end + def test_recvfrom svr = TCPServer.new("localhost", 0) th = Thread.new { |