TCP port forwarding
One of the interesting experiments we can do with TCP socket programming is to set up a TCP port forwarding. This has very good use cases. Say, for example, if you are running an insecure program like FTP in a public server that doesn't have any SSL capability to do secure communication (FTP passwords can be seen clear-text over the wires). Since this server is accessible from Internet, you must not login with your password to the server without ensuring that the passwords are encrypted. One way of doing this is to use Secure FTP or SFTP. We can use a simple SSH tunnel in order to show how this approach works. So, any communication between your local FTP client and remote FTP server will happen via this encrypted channel.
Let us run the FTP program to the same SSH server host. But create an SSH tunnel from your local machine that will give you a local port number and will directly connect you to the remote FTP server daemon.
Python has a third party sshtunnel
module that...