stargeek
PHP news website logo.
home    PHP scripts    articles    seo tools    links    search    contact    shop    realtors


Advanced Python network programming







Advanced Python network programming

Advanced Python network programming 02/17/2004 10:41 PM

Understanding Network I/O, Part 2 by George Belotsky (via The Farm) is the best tutorial on the subject of network programming I've seen yet. It provides a detailed explanation of simple threaded network clients, thread pools using the Queue module and asynchronous I/O using both Twisted and Python's asyncore library - then discusses the strengths and weaknesses of each approach.

I've also just noticed that O'Reilly provide RSS 1.0 and Atom feeds for each of their authors. Neat.




This is a GrokNews Entry: (what is grok?)





Similar Items

Advanced Python network programming

Grok Headline matches for Advanced Python network programming

Web Programming in Python


Web Programming in Python 09/05/2002 01:17 AM
Unix Review reviews the book:Web Programming in Python: Techniques for Integrating Linux, Apache, and MySQL."On the whole, though, WPIP pleasantly surprised me as a Python tutorial. The authors repeatedly show a knack for communicating the essentials of Python functionality in an understandable and succinct manner."

Socket Programming in Python


Socket Programming in Python 02/19/2004 04:28 AM
In this article I shall discuss socket programming in Python. I have explained the concepts using a sample Python client and a server.

Advanced PHP Programming


Advanced PHP Programming 06/24/2004 04:27 PM

Python to drop functional programming
support


Python to drop functional programming
support
06/24/2005 05:11 PM
I was sad to read the news item on slashdot about Python's future, a language that I find satisfying many needs. Very well, Guido rants about dropping reduce() and friends in python. Reading his reasoning, all I can say is that he might be getting behind the times.

Review: Advanced PHP Programming


Review: Advanced PHP Programming 04/09/2004 03:58 PM
Reading Advanced PHP Programming by George Schlossnagle feels like looking into the mind of a true PHP guru. I know George has an intimate knowledge of the PHP internals and Zend engine, and is an expert on PHP performance tuning. The book also covers PHP5, and most of the examples are in PHP5.

Like most of the best gurus, George has a clear style and direct approach. For example, in the chapter on templates, he says of Smarty:

Smarty is one of the most popular and widely deployed template systems for PHP... Smarty has a good bit of bloat that I think is best left alone. Like many template systems, it has grown in a number of ill-advised ways that allow complex logic to appear in the templates. Of course, features can be ignored or banned on the basis of policy.

And he writes about PEAR:

Throughout the book, I use a number of PEAR classes. In both this book and my own programming practice, I prefer to build my own components. Especially in performance-critical applications, it is often easier to design a solution that fits your exact needs and is not overburdened by extra fluff. However, it can sometimes be much easier to use an existing solution than to reinvent the wheel.

The range of technologies covered is very wide, including Templates, Caching, Databases, Sessions, RPC, Server Farms, Proxies, Benchmarking, Profiling, and Zend Internals. All the parts I read show George has spent a lot of time thinking and designing technologies in these areas. His discussion on performance tuning PHP is particular good. In many places, I can remember going through the same blind alleys he went through. At the end of each chapter, there is a further reading list - nowadays one book is never enough to cover everything. I also have a feeling that George is careful to write about areas in which he has the appropriate expertise. For example, I did not see any reference to PDF or GD usage in the index or in the text.

Another thing I like about Advanced PHP Programming is that it is not merely a discussion on advanced PHP technologies. There are several chapters on design; these include chapters on PHP coding styles, design patterns, unit-testing, CVS and packaging, designing APIs.

In conclusion, this book is a one of the two best books on PHP i have ever read. The other book is PHP and MySQL Web Development by Luke Welling and Sarah Thompson, which is an excellent introduction to PHP and MySQL. Both books complement each other. Highly recommended.


Advanced Unix Programming, 2nd Ed.


Advanced Unix Programming, 2nd Ed. 04/29/2004 04:22 PM

Advanced Unix Programming, 2nd Ed


Advanced Unix Programming, 2nd Ed 04/29/2004 09:57 PM
Slashdot Apr 30 2004 1:09AM GMT

Slashdot.org: Advanced PHP Programming
Review


Slashdot.org: Advanced PHP Programming
Review
06/25/2004 08:38 AM
Over on Slashdot.org there's a new review of the George Schlossnagle book - Advanced PHP Programming.

Advanced PHP Programming: George
Schlossnagle


Advanced PHP Programming: George
Schlossnagle
06/03/2004 06:50 PM
SitePoint, Australia - 1 hour ago ... with a high traffic site) but even if you're not able to put everything it offers into practice, there's a ton of ammo to fire back at that Java developer who ...

Dynamically Typed: Advanced PHP
Programming


Dynamically Typed: Advanced PHP
Programming
06/04/2004 09:00 AM
On Dynamically Typed today, there's a new review posting from Harry about the George Schlossnagle book "Advanced PHP Programming".

Unix Network Programming, Vol. 1


Unix Network Programming, Vol. 1 12/08/2003 02:10 PM

DIRECTV Announces Plan to Launch Next
Generation Satellites to Provide
Dramatic Expansion of High-Definition
and Advanced Programming Services.


DIRECTV Announces Plan to Launch Next
Generation Satellites to Provide
Dramatic Expansion of High-Definition
and Advanced Programming Services.
09/10/2004 01:42 AM
DIRECTV Announces Plan to Launch Next Generation Satellites to Provide Dramatic Expansion of High-Definition and Advanced Programming Services. Translation: Spaceway failed before it got off the ground (literally).

Advanced Voice Quality Technology for 3G
Network Deployments


Advanced Voice Quality Technology for 3G
Network Deployments
07/28/2004 04:43 AM
3G Jul 28 2004 8:57AM GMT

New Online Advertising Network Uses
Advanced Technology to Deliver Better
Results for Advertisers


New Online Advertising Network Uses
Advanced Technology to Deliver Better
Results for Advertisers
08/07/2004 03:12 AM
WordLinx.com is the complete solution for any online advertiser looking to get real results from their next advertising campaign. [PRWEB Aug 7, 2004]

Python and XML: XML Namespaces Support
in Python Tools, Part Three


Python and XML: XML Namespaces Support
in Python Tools, Part Three
06/30/2004 07:31 PM
In this month's Python and XML column Uche Ogbuji examines the namespace support in ElementTree, PyRXPU, and libxml.

Python and XML: XML Namespaces Support
in Python Tools, Part Two


Python and XML: XML Namespaces Support
in Python Tools, Part Two
05/13/2004 07:55 PM
In his latest Python and XML column, Uche Ogbuji continues his tour of XML namespaces support in Python tools, focusing this time on 4Suite.

Backporting from Python 2.3 to Python
2.2


Backporting from Python 2.3 to Python
2.2
06/08/2004 11:18 PM

We have a home-grown templating system at work, which I intend to dedicate an entry to some time in the future. We originally wrote it in Python 2.2, but upgraded to Python 2.3 a while ago and have since been evolving our code in that environment. Today I found a need to load the most recent version of our templating system on to a small, long neglected application that had been running the original version ever since it had enough features to be usable.

Unfortunately, this application was running on a server that only had Python 2.2. Installing Python 2.3 would have been somewhat more painful here than on other servers we run for reasons I won't go in to, so I decided to have a go at getting our current code to run under the older Python version.

In the end, I only had to make three minor changes, all at the top of the file in question.

  1. I added from __future__ import generators as the very first line of the file. We use generators (with the yield statement) in a few places - this feature was only properly added in Python 2.3, but was made available in Python 2.2 as a "future enhancement" through the aforementioned obscure import.

  2. I added True, False = 1, 0 on the next line down. Surprisingly, Python 2.2 had no support for a boolean type and instead used a test for non-zero instead. The above line defines constants that behave enough like Python 2.3's True and False to avoid any problems.

  3. I defined an enumerate function, which was introduced for real in Python 2.3. Here's the code I used:

    
    def enumerate(obj):
        for i, item in zip(range(len(obj)), obj):
            yield i, item 
    

All in all it only took around ten minutes to put the above together, after which the script worked just fine. It was interesting to see how our code had grown to rely on Python 2.3 features without us realising it.


"Statscout - Highly Scalable Network
Monitoring Software - FREE Evaluation on
your network"


"Statscout - Highly Scalable Network
Monitoring Software - FREE Evaluation on
your network"
05/10/2004 10:08 AM

Network Protocols Handbook For Cisco
CCNA, CCIE, CCNP, and MCSE, Network+ and
Security+


Network Protocols Handbook For Cisco
CCNA, CCIE, CCNP, and MCSE, Network+ and
Security+
02/01/2005 10:07 PM
The newly released "Network Protocols Handbook" by Javvin is now distributed by Ingram Books. This book is an excellent reference for Internet programmers, network pros and for people who are taking networking technology courses or trying to pass networking related certifications such as Cisco certification CCNA, CCIE, CCNP, Microsoft Certification MCSE, CompTIA certification Network+ and Security+. [PRWEB Jan 26, 2005]

HaiTel Expands Wireless Network in Haiti
with Nortel Technology; Country's First
3G Network Expected to Boost


HaiTel Expands Wireless Network in Haiti
with Nortel Technology; Country's First
3G Network Expected to Boost
04/12/2005 01:51 PM
Business Wire UK Apr 12 2005 3:30PM GMT

Free! Network Marketing Brilliance Call
with Tim Sales: A St Patrick's Day That
Will Change the Lives of Network
Marketers


Free! Network Marketing Brilliance Call
with Tim Sales: A St Patrick's Day That
Will Change the Lives of Network
Marketers
03/14/2005 06:14 PM
Overcoming Objections Defines Success in Network Marketing... and Tim Sales will teach Network Marketers how to get on the path to success this Thursday evening. [PRWEB Mar 14, 2005]

Vernier Broadens Network Admission
Management Capabilities Through Support
of Network Access Protection Technology
from Microsoft


Vernier Broadens Network Admission
Management Capabilities Through Support
of Network Access Protection Technology
from Microsoft
02/01/2005 09:14 PM
Vernier Networks Joins Microsoft’s Network Access Protection Partner Program to Deliver Secure Network Admission Management [PRWEB Jan 12, 2005]

Q Television Network Documentary
Chronicles Struggle for Gay Marriage
Rights; Network Committed to Developing
Programs That Reflect the Concerns of
the Gay and Lesbian Community


Q Television Network Documentary
Chronicles Struggle for Gay Marriage
Rights; Network Committed to Developing
Programs That Reflect the Concerns of
the Gay and Lesbian Community
06/11/2004 08:47 PM
[PRWEB Jun 11, 2004]

Connecting to Your Corporate Network
Using a Network Card


Connecting to Your Corporate Network
Using a Network Card
09/16/2004 12:54 PM

Fighting Network threats with a Network
Analyzer


Fighting Network threats with a Network
Analyzer
07/02/2004 02:53 AM

Network Provider Delivers the "Missing
Link" Between New York and New Jersey–A
Diverse–Non-Commuter Tunnel-Hudson River
Crossing-for Telecommunications Network
Operators and Users


Network Provider Delivers the "Missing
Link" Between New York and New Jersey–A
Diverse–Non-Commuter Tunnel-Hudson River
Crossing-for Telecommunications Network
Operators and Users
03/24/2005 11:05 AM
Lexent Metro Connect activates fiber optic cable in New telecommunications pipeline "bore" crossing the Hudson River. [PRWEB Mar 24, 2005]

XML with Xen and with Python


XML with Xen and with Python 12/19/2004 03:53 PM
Here is a comment on the paper "Programming with Circles, Triangles and Rectangles" by Erik Meijer et al. Perhaps interesting for XML programmers.

Python-SIP 4.1.1


Python-SIP 4.1.1 09/24/2004 03:30 PM
A tool to generate Python bindings from C++ code.

PHP Everywhere: Python vs. PHP?


PHP Everywhere: Python vs. PHP? 03/30/2005 09:12 AM
From PHP Everywhere today:

MPY (MPi for pYthon)


MPY (MPi for pYthon) 06/26/2004 05:20 PM
MPY Version 0.1 Released

Python-SIP 3.9


Python-SIP 3.9 12/08/2003 04:42 PM
A tool to generate Python bindings from C++ code.

Another look at PHP and Python


Another look at PHP and Python 02/10/2004 02:46 AM
Postscript: Some people have got the impression from this article that I am moving away from PHP. That is far from the truth. I will continue to use PHP extensively today, tomorrow and for the forseeable future.

I find Python harder than PHP.

It could be because we are programming multi-threaded networked servers in Python, and that could be inherently harder than coding dynamic web-sites. Another reason could be lack of familiarity with Python. For example, I couldn't find the equivalent of htmlspecialchars and other functions, so i had to roll my own.

Despite all these issues, we are continuing to develop this in Python because (AFAIK) PHP does not have stable networking frameworks.

So what do I like about Python?

- Neat Syntax

The use of indentation for compound statements discourages deep nesting, and thus more modular code.

- More Safety Checks

In PHP, when you search using a regular expression, an associative array is returned. In Python, a typed object, "match" is returned when a regular expression search is performed, and not a generic dictionary. You cannot perform arithmetic on strings, an explicit cast is required; neither can you concatenate numbers with strings, explicit typecasts are needed.

- Supports Multi-Threaded Apps

There exists a global lock in Python that prevents multi-threading from working effectively on multiple processors - nevertheless Python has reasonable thread support and allows me to develop reasonably responsive servers.

- Python's Compiler is Standard

Python has a standard compiler and byte-code format. There is no such standard in the PHP world, and most ISP's don't support Zend or Turck MMCache encoded PHP. Better still, a debugger is included in the package too.

- Python Fully Supports Unicode

Python 2.0 and later has full support for unicode. For example to convert big5 to unicode is the simple:

    unicode_str = unicode(tw_chinese_string, 'big5')

In contrast, see how complicated it is to perform double-byte to unicode conversions in PHP (see User Notes).

The only issue i had with the unicode support is that it doesn't come with a complete set of double-byte decoders (eg. big5, gb). After a 20 minute google search, i found this set of python cjk decoders.

And what I dislike about Python

- Python Is Not Rapid Enough?

I think that PHP is a better tool for rapid application development, especially for web-sites. Minor type issues are handled for you transparently in PHP. In Python, once a variable is set, stricter type-checking is performed on most operations.

So you can argue that Python is safer. But PHP coding is definitely more rapid.

Another thing i dislike is that Python's import/load facility does not check .py file modification dates. If i modify a .py file, Python's run-time environment will not recompile it until i restart Python, or perform a reload manually from the command-line interpreter.

- Database Access

Python does not have official database drivers, and you have to select and download these drivers yourself. It's easy to get it wrong. For example, only after coding the adodb_odbc module using PythonWin odbc extension did i realize how awful PythonWin odbc was. I then found the mxODBC extension - unfortunately the mxODBC requires commercial licensing ($75 per CPU).

- Python is Not That Popular

Popularity is relative. There are lots of Python programmers - but there are perhaps 3 times more PHP programmers than Python ones. In Malaysia, the ratio of PHP to Python programmers is probably much worse (10:1?). And there are many training centers offering PHP courses. AFAIK, there are no centers in Malaysia offering Python training. A quick search in monster.com reveals the following (numbers might change over time):

PHP: 131 jobs
http://jobsearch.monster.com/jobsearch.asp?q=php&re=0&sort=rv&tm=&fn=6 60&vw=b&cy=US&brd=1%2C1862%2C1863

Python: 41 jobs
http://jobsearch.monster.com/jobsearch.asp?q=python&re=0&sort=rv&t m=&fn=660&vw=b&cy=US&brd=1%2C1862%2C1863


Python-SIP 4.0


Python-SIP 4.0 06/23/2004 12:48 PM
A tool to generate Python bindings from C++ code.

Python 2.3.3


Python 2.3.3 12/30/2003 05:13 PM
A high-level scripting language.

Python 2.3


Python 2.3 10/28/2003 11:06 PM
Python 2.3 was released yesterday... and not a moment too soon. I was just swearing under my breath about this sort of nonsense:
>>> cosmos = technorati.cosmos('http://diveintomark.org/')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "technorati.py", line 214, in cosmos
    xmldoc = minidom.parseString(rawdata)
  File "/usr/lib/python2.2/site-packages/_xmlplus/dom/minidom.py", 
    line 1605, in parseString
    return expatbuilder.parseString(string)
, in parseString
    return builder.parseString(string)
  File
"/usr/lib/python2.2/site-packages/_xmlplus/dom/expatbuilder.py", 
    line 187, in parseString
    parser = self.getParser()
  File
"/usr/lib/python2.2/site-packages/_xmlplus/dom/expatbuilder.py", 
    line 119, in getParser
    self._parser = self.createParser()
  File
"/usr/lib/python2.2/site-packages/_xmlplus/dom/expatbuilder.py", 
    line 734, in createParser
    parser.namespace_prefixes = True
AttributeError: namespace_prefixes
OS X users, don't be discouraged by the mention of there being no MacPython version yet or daunted by the task of compiling it from source -- MacP ython 2.3 lives and is just a few glorious GUI installer clicks away.

Python-SIP 4.0.1


Python-SIP 4.0.1 07/06/2004 06:45 AM
A tool to generate Python bindings from C++ code.

ION-MP Outdoor Wireless Network Solution
Provides Faster and More Reliable
Wireless Network for Dallas Fort Worth
Auto Dealership


ION-MP Outdoor Wireless Network Solution
Provides Faster and More Reliable
Wireless Network for Dallas Fort Worth
Auto Dealership
01/06/2005 04:31 AM
ION, Inc, a wireless network solutions provider, upgrades John Eagle Dealership’s outdoor wireless network, improving throughput and reliability and eliminating monthly equipment lease costs. [PRWEB Jan 6, 2005]

ADOdb for Python


ADOdb for Python 01/26/2004 10:15 AM
In my work with Python, I found that there's no good database abstraction library, so I wrote my own. Looks familiar, doesn't it?

PHP Python
include "adodb.inc.php";
$conn = NewADOConnection('mysql');
$conn->Connect('server','user','pwd','db');
$rs = $conn->Execute('select * from tab);

while (!$rs->EOF) { print_r($rs->fields); $rs->MoveNext(); } $rs->Close(); $conn->Close();

import adodb_mysql;
conn = adodb_mysql.adodb_mysql()
conn.Connect('server','user','pwd','db')
cursor = conn.Execute('select * from tab)

while not cursor.EOF: print cursor.fields cursor.MoveNext()

cursor.Close() conn.Close()

It also supports the iterator protocol:

  cursor = conn.Execute('select * from table')
  for row in cursor:
       print row

Python does have the DB API, but it's similar to ODBC in that it provides a very minimal layer, without abstracting SELECT ... LIMIT, LOBs, string quoting, etc. Download zip.

I will try to post a comparison between developing in Python and PHP when I have more time.


Python UnZipped


Python UnZipped 01/05/2004 01:42 PM
Python is a great choice for anyone wanting to play with the increasingly popular ZIP or GZIP (not covered here) file formats, and as usual Python makes it surprisingly fun/easy! Don't believe me? In this article we'll look at creating, extracting, and adding to Zip archives using Pythons standard zipfile module and defining a set of functions you can use with your own Zip files; ending with an example which recursively scans a Zip file and sub-archives.
Grok Description matches for Advanced Python network programming
GrokA matches for Advanced Python network programming

Advanced Python network programming

The following phrases have been identified by the grok system as matching this entry:

















Also check out:


Grok

Ipod Porn on the
Rise

Brief Abstract of
Wikipedia's
Mesothelioma Cancer
page

Get first aid
instructions in your
cell phone

IE is crap
JSPWiki gains
podcasting support

U.S. Launches New
Biotechnology
Regulation Web Site

E-Gov portal up and
crawling

Afghanistan
Le Putty
MetaVNC
IBM backs 64-bit
Intel chip plan

FileMaker to Oracle
Migration with FmPro
Migrator on Mac OS X

Platypus 2.0
An Archaeology of
Browsing...

A busy weekend in
Arizona

F/A-18A Navy Blue
Angel Hornet

FlipStart.Vulcan.com
My LEGO computer at
work

"Massachusetts
liberal" meme

winners of this
years Koufax Awards

Microsoft to
Hackers: Drop That
Code!

Report: Oracle's
Price Cuts Should
Have Been Deeper

Robotic Librarian
Salesman on Nuclear
Circuit Casts Blurry
Corporate Shadow

Bush Officials Offer
Cautions on White
House Jobs Forecast

Implementing
successful shared
services in
government

Thought for the
day:Give IT back to
business

Quickfire hackers
exploit Microsoft
vulnerability

UK poor in
delivering broadband

Ofcom not focusing
on business users,
says CMA

Intel's vision of
the future

Google Co-Founder
Sees New Web Search
Competition

China's Evermore to
compete with
Microsoft

Intel Unveils New
64-Bit Xeon Server
Processor

Computerized Voting
Machines Raise
Concerns Over
Results' Accuracy

Intel unveils new
processor to battle
AMD

Vodafone helps FTSE
ring up hefty rise

Vodafone loses AT&T
bid battle

Get Off Your RSS!
Introduction to
Coldfusion Data
Structures Part IV
Queries

Kerry Beats Edwards
in Tight Wisconsin
Race (Reuters)

CreativePage updated
to 3.2

Oracle pitches
merger to PeopleSoft
shareholders

Nuclear rivals to
back talks deal

US bishop guilty of
hit-and-run

Vodafone's defeat
means longer wait
for 3G

Disable Bluetooth on
wireless phones if
you dont need it

Japanese stocks rise
on strong GDP,
DoCoMo firm

Perl Programmer -
Web Development

Morpheus Launching
Phone Service -
Simple To Create
VoIP VNOs?

Microsoft and
Security

Guiki .9 (HTMLArea3)
Yet Another
Community System
0.4.0-beta2

GrabMV 0.1
AIMSpy 0.1
what is grok?