Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions codeless banner

QIrServer Class Reference

The QIrServer class represents an Infrared TinyTP server socket. More...

    #include <QIrServer>

Inherits QObject.

Public Functions


Additional Inherited Members

Detailed Description

The QIrServer class represents an Infrared TinyTP server socket.

This class makes it possible to accept incoming Infrared connections. You can specify the service identifier that this socket represents to be automatically advertised in the IAS database.

Call listen() to make the server listen for new connections. The newConnection() signal will be emmited each time a client connects to the server.

Call nextPendingConnection() to accept the pending client connection.

When listening for connections, server service descriptor is available by calling serverService().

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

See also QIrSocket.

Member Function Documentation

QIrServer::QIrServer ( QObject * parent = 0 )

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

QIrServer::~QIrServer ()

Destroys the server.

void QIrServer::close ()

Closes the server. The server will no longer listen for incoming connections and all pending connections will be closed.

See also isListening() and socketDescriptor().

QString QIrServer::errorString () const

Returns a human-readable description of the last device error that occurred.

See also serverError().

bool QIrServer::hasPendingConnections () const

Returns true if the server has a pending connection(s); otherwise returns false.

See also nextPendingConnection() and setMaxPendingConnections().

bool QIrServer::isListening () const

Returns true if the server is currently listening for remote connections, and false otherwise.

See also close() and socketDescriptor().

bool QIrServer::listen ( const QByteArray & service, QIr::DeviceClasses classes = QIr::OBEX )

Tells the server to listen for incoming connections. The service will be automatically added to the IAS database and an Ir LSAP selector will be automatically chosen.

The classes contains the service hints for this service. If the system supports setting of the service hints they will be set into the IAS database automatically, otherwise passing this parameter will have no effect.

Returns true on success; otherwise returns false.

See also isListening().

int QIrServer::maxPendingConnections () const

Returns the maximum number of pending accepted connections. The default is 1.

See also setMaxPendingConnections() and hasPendingConnections().

void QIrServer::newConnection ()   [signal]

This signal is emitted every time a new connection is available. Call nextPendingConnection() in order to accept the connection.

See also hasPendingConnections() and nextPendingConnection().

QIrSocket * QIrServer::nextPendingConnection ()

Returns the next pending connection as a connected QIrSocket object. The function returns a pointer to a QIrSocket in QIrSocket::ConnectedState that you can use for communicating with the client.

The socket is created as a child of the server, which means that it is automatically deleted when the QIrServer object is destroyed. It is still a good idea to delete the object explicitly when you are done with it, to avoid wasting memory.

A NULL pointer is returned if this function is called when there are no pending connections.

See also hasPendingConnections().

QIr::DeviceClasses QIrServer::serverDeviceClasses () const

Returns the service hint set that this socket has been created with. The service hints are added to the IAS database automatically.

Note that this functionality might not be supported on some systems in which case this function will always return an empty set.

See also listen() and serverService().

QIrSocket::SocketError QIrServer::serverError () const

Returns the last error that has occurred.

See also errorString().

QByteArray QIrServer::serverService () const

Returns the service descriptor this socket has been created with. The service descriptor is added to the IAS database automatically.

See also listen() and serverDeviceClasses().

void QIrServer::setMaxPendingConnections ( int numConnections )

Sets the maximum number of pending accepted connections to numConnections. QIrServer will accept no more than numConnections incoming connections before nextPendingConnection() is called. By default, the limit is 1 pending connection.

See also maxPendingConnections() and hasPendingConnections().

int QIrServer::socketDescriptor () const

Returns the socket descriptor the server is currently listening on. If the server is not listening, then -1 is returned.

See also isListening().

bool QIrServer::waitForNewConnection ( int msecs = 0, bool * timedOut = 0 )

Waits for at most msecs milliseconds or until an incoming connection is available. Returns true if a connection is available; otherwise returns false. If the operation timed out and timedOut is not 0, *timedOut will be set to true.

This is a blocking function call. Its use is not advised in a single-threaded GUI application, since the whole application will stop responding until the function returns. waitForNewConnection() is mostly useful when there is no event loop available.

The non-blocking alternative is to connect to the newConnection() signal.

See also hasPendingConnections() and nextPendingConnection().

Copyright © 2009 Nokia Trademarks
Qt Extended 4.4.3