Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QBluetoothL2CapDatagramSocket Class Reference
[QtBluetoothModule]

The QBluetoothL2CapDatagramSocket class represents an L2CAP Datagram Socket. More...

    #include <QBluetoothL2CapDatagramSocket>

Inherits QBluetoothAbstractSocket.

Public Functions

Additional Inherited Members


Detailed Description

The QBluetoothL2CapDatagramSocket class represents an L2CAP Datagram Socket.

The Bluetooth L2CAP protocol provides reliable connection-oriented and unreliable connectionless data services. It is a lower layer protocol than RFCOMM.

PSM stands for Port and Service Multiplexer. The PSM value can be any odd value the range of 1-32765. For more information please see Bluetooth Specification Version 2.0 + EDR [vol 4] page 45.

The implementation of L2CAP Datagram protocol under Linux uses sockets, and is in general very similar to UDP socket programming.

The most common way to use this class is to call connect() and then write() and read() to write and read the data. If you only wish to receive data, call bind() and use the readDatagram() function.

Note that unlike UDP, the L2Cap Datagram socket must be connected first by using connect().

Note that special attention should be paid to the incoming and outgoing MTU sizes. These determine in what size chunks the data should be read / written.

NOTE: The socket is not buffered. All reads and writes happen immediately. The user must be prepared to deal with conditions where no more data could be read/written to the socket.

See also QBluetoothAbstractSocket.


Member Function Documentation

QBluetoothL2CapDatagramSocket::QBluetoothL2CapDatagramSocket ( QObject * parent = 0 )

Constructs a new QBluetoothL2CapDatagramSocket object. The parent parameter is passed to the QObject constructor.

QBluetoothL2CapDatagramSocket::~QBluetoothL2CapDatagramSocket ()

Destroys the socket.

bool QBluetoothL2CapDatagramSocket::bind ( const QBluetoothAddress & local, int psm, int mtu = 672 )

Binds an L2CAP socket to a specific local address and psm, returning true if successful; otherwise returns false. The mtu specifies the MTU to use.

bool QBluetoothL2CapDatagramSocket::connect ( const QBluetoothAddress & local, const QBluetoothAddress & remote, int psm, int incomingMtu = 672, int outgoingMtu = 672 )

Attempts to open a L2CAP connection between the local device with address local and the remote device with address remote. The L2CAP PSM to use is given by psm. This function should generally return immediately, and the socket will enter into the ConnectingState.

The incomingMtu and outgoingMtu represent the MTU sizes to use for incoming and outgoing data respectively.

The function returns true if the connection could be started, and false otherwise.

Note that the connection could still fail, the state of the socket will be sent in the stateChanged() signal.

See also connected(), stateChanged(), and waitForConnected().

int QBluetoothL2CapDatagramSocket::incomingMtu () const

Returns the MTU for incoming data. The underlying implementation will accept data packets of size no bigger than the incoming MTU. The MTU information is provided so that the read buffer size can be set appropriately.

See also outgoingMtu().

bool QBluetoothL2CapDatagramSocket::isAuthenticated () const

Returns true if the socket is authenticated.

See also securityOptions() and isEncrypted().

bool QBluetoothL2CapDatagramSocket::isEncrypted () const

Returns true if the socket is encrypted.

See also securityOptions() and isAuthenticated().

QBluetoothAddress QBluetoothL2CapDatagramSocket::localAddress () const

Returns the address of the local device. If the socket is not currently connected or bound, returns QBluetoothAddress::invalid.

See also localPsm().

int QBluetoothL2CapDatagramSocket::localPsm () const

Returns the PSM that the socket is bound to on the local device. If the socket is not bound, returns -1

See also localAddress().

int QBluetoothL2CapDatagramSocket::outgoingMtu () const

Returns the MTU for outgoing data. The underlying implementation will accept outgoing data packets of size no bigger than the outgoing MTU.

See also incomingMtu().

qint64 QBluetoothL2CapDatagramSocket::readDatagram ( char * data, qint64 maxSize, QBluetoothAddress * address = 0, int * psm = 0 )

Reads a datagram from the socket. The data specifies the pointer to a buffer of at least maxSize. The address and psm parameters specify where to store the address and psm of the remote device that sent the datagram. The result is discarded if address or psm are NULL.

If the data buffer maxSize is smaller than the incoming MTU, the data that does not fit will be discarded.

Note: Some Linux implementations do not currently return remote address information.

See also incomingMtu().

QBluetoothAddress QBluetoothL2CapDatagramSocket::remoteAddress () const

Returns the address of the remote device. If the socket is not currently connected, returns QBluetoothAddress::invalid.

See also remotePsm().

int QBluetoothL2CapDatagramSocket::remotePsm () const

Returns the PSM of the remote device. If the socket is not currently connected, returns -1.

See also remoteAddress().

QBluetooth::SecurityOptions QBluetoothL2CapDatagramSocket::securityOptions () const

Returns the security options currently active for the socket.

See also setSecurityOptions(), isAuthenticated(), and isEncrypted().

bool QBluetoothL2CapDatagramSocket::setSecurityOptions ( QBluetooth::SecurityOptions options )

Sets the security options on the socket to options. Returns true if the options could be set successfully and false otherwise.

See also securityOptions(), isAuthenticated(), and isEncrypted().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Abusons de QMap

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web