Gateway methods are for proxy host declarations (see Multi-hops) so as to pass through firewalls and proxy servers. They are not like the other methods that declare direct connections to a remote host.
A gateway method always comes with a port setting. tramp targets the port number with the gateway method localhost#random_port from where the firewall or proxy server is accessed.
Gateway methods support user name and password declarations for authenticating the corresponding firewall or proxy server. Such authentication can be passed through only if granted access by system administrators.
For authentication, this protocol uses only Basic
Authentication (see RFC 2617). When no port number is specified, this
protocol defaults to 8080.
The default port number for the socks server is 1080, if not specified otherwise.