How it works...

We created a port forwarding class, PortForwarder subclassed, from asyncore.dispatcher, which wraps around the socket object. It provides a few additional helpful functions when certain events occur, for example, when the connection is successful or a client is connected to a server socket. You have the choice of overriding the set of methods defined in this class. In our case, we only override the handle_accept() method.

Two other classes have been derived from asyncore.dispatcher. The Receiver class handles the incoming client requests and the Sender class takes this Receiver instance and processes the sent data to the clients. As you can see, these two classes override
the handle_read(), handle_write(), and writeable() methods to facilitate the
bi-directional communication between the remote host and local client.

In summary, the PortForwarder class takes the incoming client request in a local socket and passes this to the Sender class instance, which in turn uses the Receiver class instance to initiate a bi-directional communication with a remote server in the specified port.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.220.92