Python
  Home arrow Python arrow Page 3 - Bluetooth Programming in Python: Netwo...
The Best Selling PC Migration Utility.
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 
 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

Bluetooth Programming in Python: Network Programming using RFCOMM
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2007-12-12

    Table of Contents:
  • Bluetooth Programming in Python: Network Programming using RFCOMM
  • Developing Applications for RFCOMM, Step by Step
  • Listening for requests
  • Developing the Client
  • RFCOMM in the Real World

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Bluetooth Programming in Python: Network Programming using RFCOMM - Listening for requests
    (Page 3 of 5 )

    Once a socket has been bound to a port, the next step is to make it listen for incoming requests. To do this, the listen() method needs to be called on the socket object. The listen() method accepts the number of requests to be kept in queue as the argument. For example, to make a socket start listening with a queue of size 3, the statement will be 

    server_socket.listen(3)


    Accepting the requests

    Once a request is received, it has to be accepted so that communication can start. To do so, one has to call the accept() method on the socket object. The accept() method doesn't have any arguments. It returns a tuple containing the address of the client and socket object through which further communication can be accomplished. So the statement to accept a connection is

    client_socket,address=server_socket.accept()


    Sending/receiving data

    The last step is sending and/or receiving data. If the server is on a normal PC, then sending and receiving can be done using the Python library. However, if the server is on a smart phone, for example, then the library required will be based on the OS of the smart phone. For a normal PC, one would have to call send() and recv() methods on the socket object returned by the accept() method. Both accept strings as arguments. For example, if the server wants to send a message, say, "hello", the code will be

    client_socket.send("Hello from server")

    That completes the server part. Next comes the client.

    More Python Articles
    More By A.P.Rajshekhar


       · In this article, I have discussed about using RFCOMM for network programming. Please...
     

       

    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 2 hosted by Hostway