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

 
Developer Updates  
Free Website Content 
eWeek
 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? 
PYTHON

Sockets in Python
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 88
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Create a Highly Available Database Solution. Advantage Database Server can provide the availability to keep your data safe and ready for your application and users.

    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


       · I´m new to python and very thankful for this fine and concise article on Sockets in...
       · Thanks. I must agree with you on the time-saving part, by the way. With Python,...
       · Hi there.. listen() is about the specifying the size of the queue of connections to...
       · Sorry, that's a bad habit of mine for setting the maximum amount of...
       · what about in a script...you did the same thing everyone does...you show how to do...
       · In that case, you would simply put the same code into a script.
       · I'm getting the following when using your tutorial:>> mySocket.sendto('Wherefore...
       · I think there's an error in the client code for datagrams in this article. The...
       · nice article :)) and ty very much
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway