MeeGo 1.2 Harmattan Developer Documentation Develop for the Nokia N9

QRfcommServer Class Reference

The QRfcommServer class provides an RFCOMM server. More...

 #include <QRfcommServer>

Inherits: QObject.

This class was introduced in Qt Mobility 1.2.

Public Functions

QRfcommServer ( QObject * parent = 0 )
~QRfcommServer ()
void close ()
bool hasPendingConnections () const
bool isListening () const
bool listen ( const QBluetoothAddress & address = QBluetoothAddress(), quint16 port = 0 )
int maxPendingConnections () const
QBluetoothSocket * nextPendingConnection ()
QBluetooth::SecurityFlags securityFlags () const
QBluetoothAddress serverAddress () const
quint16 serverPort () const
void setMaxPendingConnections ( int numConnections )
void setSecurityFlags ( QBluetooth::SecurityFlags security )
  • 29 public functions inherited from QObject

Signals

void newConnection ()

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

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.

See also QBluetoothServiceInfo and QBluetoothSocket.

Member Function Documentation

QRfcommServer::QRfcommServer ( QObject * parent = 0 )

Constructs an RFCOMM server with parent.

QRfcommServer::~QRfcommServer ()

Destroys the RFCOMM server.

void QRfcommServer::close ()

Closes and resets the listening socket.

bool QRfcommServer::hasPendingConnections () const

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

bool QRfcommServer::isListening () const

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

bool QRfcommServer::listen ( const QBluetoothAddress & address = QBluetoothAddress(), quint16 port = 0 )

Start listening for incoming connections to address on port.

Returns true if the operation succeeded and the RFCOMM server is listening for incoming connections; otherwise returns false.

See also isListening() and newConnection().

int QRfcommServer::maxPendingConnections () const

Returns the maximum number of pending connections.

See also setMaxPendingConnections().

void QRfcommServer::newConnection () [signal]

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.

See also nextPendingConnection() and hasPendingConnections().

QBluetoothSocket * QRfcommServer::nextPendingConnection ()

Returns a pointer QBluetoothSocket for the next pending connection. It is the callers responsibility to delete pointer.

QBluetooth::SecurityFlags QRfcommServer::securityFlags () const

Returns the Bluetooth security flags.

See also setSecurityFlags().

QBluetoothAddress QRfcommServer::serverAddress () const

Returns the server address.

quint16 QRfcommServer::serverPort () const

Returns the server's port number.

void QRfcommServer::setMaxPendingConnections ( int numConnections )

Sets the maximum number of pending connections to numConnections.

See also maxPendingConnections().

void QRfcommServer::setSecurityFlags ( QBluetooth::SecurityFlags security )

Sets the Bluetooth security flags to security. This function must be called prior to calling listen().

See also securityFlags().