Getting ready

You need to install the third-party Python module, twisted. This can be grabbed from PyPI (https://pypi.org/project/Twisted/). Both on Windows and Linux hosts, you may need to install some additional packages. The installation procedure is documented at https://twistedmatrix.com/trac/.

Follow the following guidelines to install Twisted in your Debian/Ubuntu based Linux distributions.

Twisted suggests against installing anything into global site-package. It recommends using virtualenv to set up isolated publish/subscribe modules. virtualenv is a product aimed to create isolated execution environments for Python. While we can indeed make Twisted work by directly installing the bundles using pip, we respect the suggestion of Twisted, and follow their installation guidelines for this recipe. Read more on this at https://hynek.me/articles/virtualenv-lives/.

You may install virtualenv by the following, in Ubuntu:

$ sudo apt install virtualenv

Now you are ready to initialize the execution environment with Twisted, by following this command:

$ virtualenv try-twisted

The preceding command uses the current directory to set up the Python test environment under the subdirectory try-twisted. You may activate/initialize the environment as indicated here:

$ . try-twisted/bin/activate
$ sudo pip install twisted[tls]
  

Once you have installed Twisted (following the preceding instructions or otherwise), you will be able to build asynchronous network applications. To make sure you have installed Twisted successfully, you may execute the following:

$ twist --help
Usage: twist [options] plugin [plugin_options]
Options:
      --reactor=     The name of the reactor to use. (options: "asyncio", "kqueue", "glib2", "win32", "iocp", "default", "cf", "epoll", "gtk2", "poll", "gtk3", "gi", "wx", "select")
  ..
Commands:
    conch        A Conch SSH service.
    ftp          An FTP server.
    manhole      An interactive remote debugger service accessible via telnet and ssh and providing syntax coloring and basic line editing functionality.
    web          A general-purpose web server which can serve from a filesystem or application resource.
  
..................Content has been hidden....................

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