04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

312 CHAPTER 14 ■ NETWORK PROGRAMMING<br />

Twisted. This framework, from Twisted Matrix Laboratories, is very rich and complex,<br />

with support for most major network protocols. Even though it is large, and some of the<br />

idioms used may seem a bit foreign, basic usage is very simple and intuitive. The Twisted<br />

framework is also asynchronous, so it’s very efficient and scalable. If you have Twisted<br />

available, it may very well be the best choice for many custom network applications.<br />

New Functions in This Chapter<br />

Function<br />

urllib.urlopen(url[, data[, proxies]])<br />

urllib.urlretrieve(url[, fname[, hook[, data]]])<br />

urllib.quote(string[, safe])<br />

Description<br />

Opens a file-like object from a URL<br />

Downloads a file from a URL<br />

Quotes special URL characters<br />

urllib.quote_plus(string[, safe]) The same, but quotes space as +<br />

urllib.unquote(string)<br />

urllib.unquote_plus(string)<br />

urllib.urlencode(query[, doseq])<br />

select.select(iseq, oseq, eseq[, timeout])<br />

select.poll()<br />

reactor.listenTCP(port, factory)<br />

reactor.run()<br />

The reverse of quote<br />

The reverse of quote_plus<br />

Encodes mapping for use in CGI<br />

queries<br />

Finds sockets ready for<br />

reading/writing<br />

Creates a poll object, for polling<br />

sockets<br />

Twisted function; listens for<br />

connections<br />

Twisted function; main server loop<br />

What Now?<br />

You thought we were finished with network stuff now, huh? Not a chance. The next chapter<br />

deals with a quite specialized and much-publicized entity in the world of networking: the Web.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!