in reply to Re^5: How do you use Net::OpenSSH to query mysql database via ssh tunnel
in thread How do you use Net::OpenSSH to query mysql database via ssh tunnel

The way I understand it, what appears to be going on is this: Net::OpenSSH is setting up a new ssh process on the local machine and giving it the -W option (ssh). This causes the ssh process on the local machine to establish a tunnel to the remote side, where it connects to the given remote address+port. On the local end, it provides that TCP connection over the ssh process's STDIN and STDOUT. Net::OpenSSH then creates a new socketpair, attaches the STDIN and STDOUT streams of the slave SSH process to one end and returns the other as $socket (I'm partially quoting from the option stdinout_socket).