QRfcommServer

Since: 1.2

#include <QtConnectivity/QRfcommServer>

More information will be added here shortly. For now, you'll find more extensive information about this class in the Qt reference for 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.


Overview

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 ()

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 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().

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: 2015-03-26



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

comments powered by Disqus