Use Socket instead of TCPSocket/TCPServer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2016-11-19 11:01:55 +00:00
parent 77403c88cd
commit 73199e1e82

View File

@ -311,7 +311,7 @@ module Net
# Constructs a socket with +host+ and +port+.
#
# If SOCKSSocket is defined and the environment (ENV) defines
# SOCKS_SERVER, then a SOCKSSocket is returned, else a TCPSocket is
# SOCKS_SERVER, then a SOCKSSocket is returned, else a Socket is
# returned.
def open_socket(host, port) # :nodoc:
return Timeout.timeout(@open_timeout, Net::OpenTimeout) {
@ -319,7 +319,7 @@ module Net
@passive = true
sock = SOCKSSocket.open(host, port)
else
sock = TCPSocket.open(host, port)
sock = Socket.tcp(host, port)
end
}
end
@ -507,7 +507,7 @@ module Net
# Constructs a TCPServer socket
def makeport # :nodoc:
TCPServer.open(@bare_sock.local_address.ip_address, 0)
Addrinfo.tcp(@bare_sock.local_address.ip_address, 0).listen
end
private :makeport
@ -557,7 +557,7 @@ module Net
if !resp.start_with?("1")
raise FTPReplyError, resp
end
conn = sock.accept
conn, peeraddr = sock.accept
sock.shutdown(Socket::SHUT_WR) rescue nil
sock.read rescue nil
ensure