Home · All Classes · Grouped Classes · Annotated · Functions

QBluetoothL2CapServer Class Reference

The QBluetoothL2CapServer class represents an L2CAP server socket. More...

    #include <QBluetoothL2CapServer>

Inherits QBluetoothAbstractServer.

Public Functions

Additional Inherited Members


Detailed Description

The QBluetoothL2CapServer class represents an L2CAP server socket.

This class makes it possible to accept incoming L2CAP connections. You can specify the address and the L2CAP PSM to listen on.

Call listen() to make the server listen for new connections. The newConnection() signal will be emmited each time a client connects to the server. The MTU to use should be specified during the listen() call.

Security options controlling the authentication and encryption of the Bluetooth link on the socket can be specified at any time by calling setSecurityOptions(). Currently this will only affect all future connections, not connections which are active or pending.

Call nextPendingConnection() to accept the pending client connection.

When listening for connections, server address and PSM are available by calling serverAddress() and serverPsm().

Calling close() will make the QBluetoothL2CapServer stop listening for connections and delete all pending connections.

    // Create a new L2CapServer on PSM 25
    QBluetoothL2CapServer *server = new QBluetoothL2CapServer;
    server->listen(QBluetoothAddress::any, 25);

    // wait for newConnection() signal

    QBluetoothL2CapSocket *sock =
        qobject_cast<QBluetoothL2CapSocket *>( sock->nextPendingConnection() );

    server->close();

See also QBluetoothL2CapSocket.


Member Function Documentation

QBluetoothL2CapServer::QBluetoothL2CapServer ( QObject * parent = 0 )

Constructs a new QBluetoothL2CapServer with parent parent. The server is in the UnconnectedState.

QBluetoothL2CapServer::~QBluetoothL2CapServer ()

Destroys the server.

bool QBluetoothL2CapServer::isAuthenticated () const

Returns true if the socket is authenticated.

See also securityOptions() and isEncrypted().

bool QBluetoothL2CapServer::isEncrypted () const

Returns true if the socket is encrypted.

See also securityOptions() and isAuthenticated().

bool QBluetoothL2CapServer::listen ( const QBluetoothAddress & local, int psm, int mtu = 672 )

Tells the server to listen for incoming connections on address local and PSM psm. The mtu parameter holds the MTU to use for the server.

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.

Returns true if the server successfully started listening; otherwise returns false. If the server was already listening, returns false.

See also isListening().

int QBluetoothL2CapServer::mtu () const

Returns the MTU that should be used for this server. By default the MTU is set to be 672 bytes. If the socket is not listening, or an error occurred, returns -1.

QBluetooth::SecurityOptions QBluetoothL2CapServer::securityOptions () const

Returns the security options currently active for the socket.

See also setSecurityOptions().

QBluetoothAddress QBluetoothL2CapServer::serverAddress () const

Returns the address the server is currently listening on. If the server is not listening, returns QBluetoothAddress::invalid.

See also serverPsm().

int QBluetoothL2CapServer::serverPsm () const

Returns the L2CAP PSM the server is currently listening on. If the server is not listening, returns -1.

See also serverAddress().

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

Returns true if able to set the security options of the socket to be options; otherwise returns false. Note that under the current Linux implementation only new connections will be affected by the change in security options. Existing and pending connections will not be affected.

See also securityOptions().


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3