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:
parent
77403c88cd
commit
73199e1e82
@ -311,7 +311,7 @@ module Net
|
|||||||
# Constructs a socket with +host+ and +port+.
|
# Constructs a socket with +host+ and +port+.
|
||||||
#
|
#
|
||||||
# If SOCKSSocket is defined and the environment (ENV) defines
|
# 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.
|
# returned.
|
||||||
def open_socket(host, port) # :nodoc:
|
def open_socket(host, port) # :nodoc:
|
||||||
return Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
return Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
||||||
@ -319,7 +319,7 @@ module Net
|
|||||||
@passive = true
|
@passive = true
|
||||||
sock = SOCKSSocket.open(host, port)
|
sock = SOCKSSocket.open(host, port)
|
||||||
else
|
else
|
||||||
sock = TCPSocket.open(host, port)
|
sock = Socket.tcp(host, port)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -507,7 +507,7 @@ module Net
|
|||||||
|
|
||||||
# Constructs a TCPServer socket
|
# Constructs a TCPServer socket
|
||||||
def makeport # :nodoc:
|
def makeport # :nodoc:
|
||||||
TCPServer.open(@bare_sock.local_address.ip_address, 0)
|
Addrinfo.tcp(@bare_sock.local_address.ip_address, 0).listen
|
||||||
end
|
end
|
||||||
private :makeport
|
private :makeport
|
||||||
|
|
||||||
@ -557,7 +557,7 @@ module Net
|
|||||||
if !resp.start_with?("1")
|
if !resp.start_with?("1")
|
||||||
raise FTPReplyError, resp
|
raise FTPReplyError, resp
|
||||||
end
|
end
|
||||||
conn = sock.accept
|
conn, peeraddr = sock.accept
|
||||||
sock.shutdown(Socket::SHUT_WR) rescue nil
|
sock.shutdown(Socket::SHUT_WR) rescue nil
|
||||||
sock.read rescue nil
|
sock.read rescue nil
|
||||||
ensure
|
ensure
|
||||||
|
Loading…
x
Reference in New Issue
Block a user