Python
  Home arrow Python arrow Sockets in Python
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PYTHON

Sockets in Python
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 102
    2004-12-28


    Table of Contents:
  • Sockets in Python
  • The Basics
  • Connecting to the Server
  • Sockets...Simplified
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Sockets in Python
    ( Page 1 of 5 )

    Sockets are the lead pipes of computer networks: they let you connect with other devices so that information can flow freely. As you might expect, they're widely used on the Internet. Peyton McCullough explains how to code sockets in Python.

    Introduction

    One of the must-know features of any language is sockets, and, no, I’m not talking about the ones positioned on your ceiling. While many novice scripters will run away at the sound of the word, sockets in Python are not hard to learn and work with at all. In this article, I will explain the basics and even apply sockets in a real-world situation.

    Please note that this article assumes that you have a basic command of the Python language. If not, you can either read the official tutorial or buy a book – or both. If you’re looking for a good book, you should head over to O’Reilly & Associates.

    With that stated, let’s get started.

    The Anatomy of a Socket

    Let’s start off simple: what is a socket? The easiest way to learn is to compare computer sockets to lead pipes. Let’s say you have some sort of machine that has two pipes. One pipe pumps in water and the other pipe pumps out water. This will be your server. Now, imagine you have a simple box that has one pipe going through it. Let’s say that you hook it up to your pump machine. It will receive the water from the machine and then give water back. This will be your client. If you wanted to, you could hook up more machines and pipes to this to form a network of clients and servers.

    Sockets are useful. The Web browser that you are viewing this page with is connecting to the server that this page is in by way of a socket. If you were to connect to one of your favorite online games or chat networks, you would be using sockets as well. As you can see, sockets are both both powerful and widely-used.



     
     
    >>> More Python Articles          >>> More By Peyton McCullough
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek