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.

The Rhetorical Nature of XML: Constructing Knowledge in Networked Environments

Computation and Storage in the Cloud: Understanding the Trade-Offs

Software Engineering: Principles and Practice (3rd Edition)

Lulzsec

 

 

 

 

 

 

 

 

 

 

 

 

 

requests[fileno].decode()[:-2]) elif event & select.EPOLLOUT: byteswritten = connections[fileno].send(responses[fileno]) responses[fileno] = responses[fileno][byteswritten:] if len(responses[fileno]) == 0: self.epoll.modify(fileno, 0) connections[fileno].shutdown(socket.SHUT_RDWR) elif event & select.EPOLLHUP: self.epoll.unregister(fileno) connections[fileno].close() del connections[fileno] finally: self.epoll.unregister(self.sock.fileno()) self.epoll.close() self.sock.close() if __name__ ==

have full control over your web server, you need to launch your customized HTTP server.. Listing 4.2 gives the following code for the custom HTTP web server: #!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - 4 # This program is optimized for Python 2.7. # It may run on any other version with/without modifications. import argparse 88 Chapter 4 import sys from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer DEFAULT_HOST = '127.0.0.1' DEFAULT_PORT = 8800 class

across a proxy server as follows: #!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - 4 # This program is optimized for Python 2.7. # It may run on any other version with/without modifications. import urllib URL = 'https://www.github.com' PROXY_ADDRESS = "165.24.10.8:8080" if __name__ == '__main__': resp = urllib.urlopen(URL, proxies = {"http" : PROXY_ADDRESS}) print "Proxy server returns response headers: %s " %resp.headers 96 Chapter 4 If you run this script, it will show

with/without modifications. from pygeocoder import Geocoder def search_business(business_name): results = Geocoder.geocode(business_name) for result in results: print result if __name__ == '__main__': business_name = "Argos Ltd, London" print "Searching %s" %business_name search_business(business_name) This recipe will print the address of Argos Ltd., as shown. The output may vary slightly based on the output from your installed geocoding library: $ python 6_1_search_business_addr.py Searching

on any other version with/without modifications. import socket def find_service_name(): protocolname = 'tcp' for port in [80, 25]: print "Port: %s => service name: %s" %(port, socket. getservbyport(port, protocolname)) print "Port: %s => service name: %s" %(53, socket. getservbyport(53, 'udp')) if __name__ == '__main__': find_service_name() 13 Sockets, IPv4, and Simple Client/Server Programming If you run this script, you will see the following output: $ python 1_4_finding_service_name.py Port:

Download sample

Download