# File lib/net/ssh/service/forward.rb, line 51
51:     def local(*args)
52:       if args.length < 3 || args.length > 4
53:         raise ArgumentError, "expected 3 or 4 parameters, got #{args.length}"
54:       end
55: 
56:       bind_address = "127.0.0.1"
57:       bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\D/
58: 
59:       local_port = args.shift.to_i
60:       remote_host = args.shift
61:       remote_port = args.shift.to_i
62: 
63:       socket = TCPServer.new(bind_address, local_port)
64: 
65:       @local_forwarded_ports[[local_port, bind_address]] = socket
66: 
67:       session.listen_to(socket) do |server|
68:         client = server.accept
69:         debug { "received connection on #{bind_address}:#{local_port}" }
70: 
71:         channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :long, local_port) do |achannel|
72:           achannel.info { "direct channel established" }
73:         end
74: 
75:         prepare_client(client, channel, :local)
76:   
77:         channel.on_open_failed do |ch, code, description|
78:           channel.error { "could not establish direct channel: #{description} (#{code})" }
79:           channel[:socket].close
80:         end
81:       end
82:     end