QL2capServer

Since: 1.2

#include <QtConnectivity/QL2capServer>

The QL2capServer class provides an L2CAP server.

QL2capServer is used to implement Bluetooth services over L2CAP.

Start listening for incoming connections with listen(). The newConnection() signal is emitted when a new connection is established. Call nextPendingConnection() to get a QBluetoothSocket for the new connection.

to enable other devices to find your service create a QBluetoothServiceInfo with the applicable attributes for your service and register it with QBluetoothServiceInfo::registerService(). Call serverPort() to get the L2CAP port number that is being used.

L2Cap is not supported on Blackberry.


Overview

Protected Attributes Index

QL2capServerPrivate *d_ptr

Public Functions Index

QL2capServer (QObject *parent=0)
~QL2capServer ()
voidclose ()
boolhasPendingConnections () const
boolisListening () const
boollisten (const QBluetoothAddress &address=QBluetoothAddress(), quint16 port=0)
intmaxPendingConnections () const
QBluetoothSocket *nextPendingConnection ()
QBluetooth::SecurityFlagssecurityFlags () const
QBluetoothAddressserverAddress () const
quint16serverPort () const
voidsetMaxPendingConnections (int numConnections)
voidsetSecurityFlags (QBluetooth::SecurityFlags security)

Signals Index

Protected Attributes

QL2capServerPrivate * d_ptr ()

Public Functions

QL2capServer (

Constructs an L2CAP server with parent.

~QL2capServer ()

Destructor.

void close ()

Closes and resets the listening socket.

bool hasPendingConnections ()

Returns true if a connection is pending; otherwise returns false.

bool isListening ()

Returns true if the L2CAP server is listening for incoming connections; otherwise returns false.

bool listen (

Start listening for incoming connections to address on port.

int maxPendingConnections ()

Returns the maximum number of pending connections.

QBluetoothSocket * nextPendingConnection ()

Returns a pointer to a QBluetoothSocket for the next pending connection.

It is the callers responsibility to delete the pointer.

QBluetooth::SecurityFlags securityFlags ()

Returns the Bluetooth security flags.

QBluetoothAddress serverAddress ()

Returns the server address.

quint16 serverPort ()

Returns the server's port number.

void setMaxPendingConnections (
  • intnumConnections)

Sets the maximum number of pending connections to numConnections.

void setSecurityFlags (
  • QBluetooth::SecurityFlagssecurity)

Sets the Bluetooth security flags to security.

This function must be called prior to calling listen().

Signals

void newConnection ()

This signal is emitted when a new connection is available.

The connected slot should call nextPendingConnection() to get a QBluetoothSocket object to send and receive data over the connection.

Last modified: 2014-09-30



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus