Python Network Programming Cookbook

Python Network Programming Cookbook

Language: English

Pages: 270

ISBN: 1849513465

Format: PDF / Kindle (mobi) / ePub

Over 70 detailed recipes to develop practical solutions for a wide range of realworld network programming tasks

About This Book

  • Demonstrates how to write various besopke client/server networking applications using standard and popular third-party Python libraries
  • Learn how to develop client programs for networking protocols such as HTTP/HTTPS, SMTP, POP3, FTP, CGI, XML-RPC, SOAP and REST
  • Provides practical, hands-on recipes combined with short and concise explanations on code snippets

Who This Book Is For

If you are a network programmer, system/network administrator, or a web application developer, this book is ideal for you. You should have a basic familiarity with the Python programming language and TCP/IP networking concepts. However if you are a novice, you will develop an understanding of the concepts as you progress with this book. This book will serve as a supplementary material for developing hands-on skills in any academic course on network programming.

What You Will Learn

  • Develop TCP/IP networking client/server applications
  • Administer local machines' IPv4/IPv6 network interfaces
  • Write multi-purpose efficient web clients for HTTP and HTTPS protocols
  • Create e-mail clients to work with common e-mail protocols such as SMTP, POP3, IMAP, and so on.
  • Scrape websites and search for useful information
  • Perform remote system administration tasks over Telnet and SSH connections
  • Interact with popular websites via web services such as XML-RPC, SOAP, and REST APIs
  • Monitor and analyze major common network security vulnerabilities

In Detail

Python is an excellent language to use to write code and have fun by prototyping applications quickly. The presence of lots of third-party libraries, also known as batteries, makes it even more easier and faster to prototype an application or to implement a new algorithm. If you are interested in creating the building blocks for many practical web and networking applications that rely on networking protocols then this book is a must-have.

This book highlights major aspects of network programming in Python starting from writing simple networking clients, to developing complex screen-scraping and network security monitoring scripts. It creates the building blocks for many practical web and networking applications that rely on various networking protocols. This book presents the power and beauty of Python in solving the numerous real-world tasks in the area of network programming, system and network administration, network monitoring, and web-application development.

This book develops your ability to solve a wide range of network programming tasks in Python. We will start by exploring the Python standard library functions to create client/server network and manipulate your local networking resources available under both IPv4 and IPv6. The practical focus continues with creating web and email clients, scraping web pages, fetching information from various websites, and searching for information on the Web such as Amazon, Flickr, and other sites. It further develops your skills to analyze your network security vulnerabilities using advanced network packet capture and analysis techniques.

Introduction to Computer Theory (2nd Edition)

Genetic Programming Theory and Practice VII (Genetic and Evolutionary Computation)

Randomized Algorithms

Database Systems: The Complete Book (GOAL Series)

Countdown to Zero Day: Stuxnet and the Launch of the World's First Digital Weapon





















class EchoServer(object): """ An echo server using diesel""" def handler(self, remote_addr): """Runs the echo server""" host, port = remote_addr[0], remote_addr[1] print "Echo client connected from: %s:%d" %(host, port) while True: try: 49 Multiplexing Socket I/O for Better Performance message = diesel.until_eol() your_message = ': '.join(['You said', message]) diesel.send(your_message) except Exception, e: print "Exception:",e def main(server_port): app = diesel.Application() server = for Windows-specific implementation. How to do it... You can use the fnctl module to query the IP address on your machine. 67 IPv6, Unix Domain Sockets, and Network Interfaces Listing 3.5 shows us how to find the IP address for a specific interface on your machine, as follows: #!/usr/bin/env python # Python Network Programming Cookbook -- Chapter – 3 # This program is optimized for Python 2.7. # It may run on any other version with/without

Screen-scraping and Other Practical Applications import argparse import os import urllib ERROR_STRING = '' def find_lat_long(city): """ Find geographic coordinates """ # Encode query string into Google maps URL url = '' + urllib.quote(city) + '&output=js' print 'Query: %s' % (url) # Get XML location from Google maps xml = urllib.urlopen(url).read() if ERROR_STRING in xml: print '\nGoogle cannot interpret the city.' return else: # Strip lat/long coordinates from

Applications How to do it... We would like to define a search_repository() function that will take the name of author (also known as coder), repository, and search key. In return, it will give us back the available result against the search key. From the GitHub API, the following are the available search keys: issues_url, has_wiki, forks_url, mirror_url, subscription_url, notifications_url, collaborators_url, updated_at, private, pulls_url, issue_comment_url, labels_url, full_name, owner,

=>{/other_ user} events_url =>{/privacy} organizations_url => url => gists_url =>{/gist_id} html_url => subscriptions_url => avatar_url =>

Download sample