Since: 1.2

#include <QtConnectivity/QRfcommServer>

The QRfcommServer class provides an RFCOMM server.

QRfcommServer is used to implement Bluetooth services over RFCOMM.

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 RFCOMM channel number that is being used.


Protected Attributes Index

QRfcommServerPrivate *d_ptr

Public Functions Index

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

Signals Index

Protected Attributes

QRfcommServerPrivate * d_ptr ()

Public Functions

QRfcommServer (

Constructs an RFCOMM server with parent.

~QRfcommServer ()


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 RFCOMM server is listening for incoming connections; otherwise returns false.

bool listen (

Start listening for incoming connections to address on port.

bool listen (

int maxPendingConnections ()

Returns the maximum number of pending connections.

QBluetoothSocket * nextPendingConnection ()

Returns a pointer QBluetoothSocket for the next pending connection.

It is the callers responsibility to delete 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().


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: 2015-01-22

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

comments powered by Disqus