Python
  Home arrow Python arrow Page 4 - Bluetooth Programming in Python: Netwo...
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 
IBM Rational Software Development Conference
 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 - Developing the Client
    (Page 4 of 5 )

    The steps necessary to developing the client are almost the same as those we needed to take to develop the server. The steps are

    1. Create a socket
    2. Connect to a device
    3. Sending/receiving data

    The first and third steps are same as that of creating the server. So only the second step needs scrutinizing. I explain the details below.

    Create a socket

    Just as with a server socket, to create a client socket the BluetoothSocket() method needs to be called with RFCOMM as the protocol. So, to create a socket that would connect to a server, the statement will be

    client_socket= Bluetooth.BluetoothSocket(Bluetooth.RFCOMM)


    Connect to a device

    To connect to a server, the client needs to know the address of the server. With Bluetooth, the address will be the address of the device, which is of the form "XX:XX:XX:XX:XX". So, to connect to a server running on a device with an address of "01:23:45:67:89:AB",  the connect() method needs to be called on the socket object with the port number and address of the server. For example, if the server port number is 4000 and the address is "01:23:45:67:89:AB", then the statement to connect to it is 

    address="01:23:45:67:89:AB"

    port=4000

    client_sock.connect((address, port))


    Sending/receiving data

    At the client side too, the way to send and /or receive data is the same as that at the server side. So, to receive any data from the server, the statement would be

    data = client_sockect.recv(1024)

    print "received [%s]" % data


    That completes the steps necessary to create a client and a server. Next, let us see how to develop a server that transfers a file using Bluetooth and RFCOMM.

    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