QtMobility Reference Documentation

QLlcpSocket Class Reference

The QLlcpSocket class provides an NFC LLCP socket. More...

 #include <QLlcpSocket>

Inherits: QIODevice.

This class was introduced in Qt Mobility 1.2.

Public Types

enum SocketError { UnknownSocketError, RemoteHostClosedError, SocketAccessError, SocketResourceError }
enum SocketState { UnconnectedState, ConnectingState, ConnectedState, ClosingState, BoundState, ListeningState }

Public Functions

QLlcpSocket ( QObject * parent = 0 )
~QLlcpSocket ()
bool bind ( quint8 port )
void connectToService ( QNearFieldTarget * target, const QString & serviceUri )
void disconnectFromService ()
SocketError error () const
bool hasPendingDatagrams () const
qint64 pendingDatagramSize () const
qint64 readDatagram ( char * data, qint64 maxSize, QNearFieldTarget ** target = 0, quint8 * port = 0 )
SocketState state () const
virtual bool waitForConnected ( int msecs = 30000 )
virtual bool waitForDisconnected ( int msecs = 30000 )
qint64 writeDatagram ( const char * data, qint64 size )
qint64 writeDatagram ( const char * data, qint64 size, QNearFieldTarget * target, quint8 port )
qint64 writeDatagram ( const QByteArray & datagram )
qint64 writeDatagram ( const QByteArray & datagram, QNearFieldTarget * target, quint8 port )

Reimplemented Public Functions

virtual qint64 bytesAvailable () const
virtual bool canReadLine () const
virtual void close ()
virtual bool isSequential () const
virtual bool waitForBytesWritten ( int msecs = 30000 )
virtual bool waitForReadyRead ( int msecs = 30000 )
  • 33 public functions inherited from QIODevice
  • 29 public functions inherited from QObject

Signals

void connected ()
void disconnected ()
void error ( QLlcpSocket::SocketError socketError )
void stateChanged ( QLlcpSocket::SocketState socketState )

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
  • 5 protected functions inherited from QIODevice
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QLlcpSocket class provides an NFC LLCP socket.

NFC LLCP protocol is a peer-to-peer communication protocol between two NFC compliant devices.

Member Type Documentation

enum QLlcpSocket::SocketError

This enum describes the errors that can occur. The most recent error can be retrieved through a call to error().

ConstantValueDescription
QLlcpSocket::UnknownSocketErrorQAbstractSocket::UnknownSocketErrorAn unidentified error has occurred.
QLlcpSocket::RemoteHostClosedErrorQAbstractSocket::RemoteHostClosedErrorThe remote host closed the connection.
QLlcpSocket::SocketAccessErrorQAbstractSocket::SocketAccessErrorThe socket operation failed because the application lacked the required privileges.
QLlcpSocket::SocketResourceErrorQAbstractSocket::SocketResourceErrorThe local system ran out of resources (e.g., too many sockets).

enum QLlcpSocket::SocketState

This enum describes the different state in which a socket can be.

ConstantValueDescription
QLlcpSocket::UnconnectedStateQAbstractSocket::UnconnectedStateThe socket is not connected.
QLlcpSocket::ConnectingStateQAbstractSocket::ConnectingStateThe socket has started establishing a connection.
QLlcpSocket::ConnectedStateQAbstractSocket::ConnectedStateA connection is established.
QLlcpSocket::ClosingStateQAbstractSocket::ClosingStateThe socket is about to close.
QLlcpSocket::BoundStateQAbstractSocket::BoundStateThe socket is bound to a local port (for servers).
QLlcpSocket::ListeningStateQAbstractSocket::ListeningStateThe socket is listening for incoming connections (for internal use).

Member Function Documentation

QLlcpSocket::QLlcpSocket ( QObject * parent = 0 )

Construct a new unconnected LLCP socket with parent.

QLlcpSocket::~QLlcpSocket ()

Destroys the LLCP socket.

bool QLlcpSocket::bind ( quint8 port )

Binds the LLCP socket to local port. Returns true on success; otherwise returns false.

qint64 QLlcpSocket::bytesAvailable () const [virtual]

Reimplemented from QIODevice::bytesAvailable().

bool QLlcpSocket::canReadLine () const [virtual]

Reimplemented from QIODevice::canReadLine().

void QLlcpSocket::close () [virtual]

Reimplemented from QIODevice::close().

Disconnects the socket.

void QLlcpSocket::connectToService ( QNearFieldTarget * target, const QString & serviceUri )

Connects to the service identified by the URI serviceUri on target.

void QLlcpSocket::connected () [signal]

This signal is emitted after connectToService() has been called and a connection has been successfully established.

See also connectToService() and disconnected().

void QLlcpSocket::disconnectFromService ()

Disconnects the socket.

void QLlcpSocket::disconnected () [signal]

This signal is emitted when the socket has been disconnected.

See also disconnectFromService().

SocketError QLlcpSocket::error () const

Returns the type of error that last occurred.

void QLlcpSocket::error ( QLlcpSocket::SocketError socketError ) [signal]

This signal is emitted when an error occurs. The socketError parameter describes the error.

bool QLlcpSocket::hasPendingDatagrams () const

Returns true if at least one datagram (service data units) is waiting to be read; otherwise returns false.

See also pendingDatagramSize() and readDatagram().

bool QLlcpSocket::isSequential () const [virtual]

Reimplemented from QIODevice::isSequential().

Always returns true.

qint64 QLlcpSocket::pendingDatagramSize () const

Returns the size of the first pending datagram (service data unit). If there is no datagram available, this function returns -1.

See also hasPendingDatagrams() and readDatagram().

qint64 QLlcpSocket::readDatagram ( char * data, qint64 maxSize, QNearFieldTarget ** target = 0, quint8 * port = 0 )

Receives a datagram no larger than maxSize bytes and stores it in data. The sender's details are stored in target and port (unless the pointers are 0).

Returns the size of the datagram on success; otherwise returns -1.

If maxSize is too small, the rest of the datagram will be lost. To avoid loss of data, call pendingDatagramSize() to determine the size of the pending datagram before attempting to read it. If maxSize is 0, the datagram will be discarded.

See also writeDatagram(), hasPendingDatagrams(), and pendingDatagramSize().

SocketState QLlcpSocket::state () const

Returns the state of the socket.

void QLlcpSocket::stateChanged ( QLlcpSocket::SocketState socketState ) [signal]

This signal is emitted when the state of the socket changes. The socketState parameter describes the new state.

bool QLlcpSocket::waitForBytesWritten ( int msecs = 30000 ) [virtual]

Reimplemented from QIODevice::waitForBytesWritten().

bool QLlcpSocket::waitForConnected ( int msecs = 30000 ) [virtual]

Waits until the socket is connected, up to msecs milliseconds. If the connection has been established, this function returns true; otherwise it returns false. In the case where it returns false, you can call error() to determine the cause of the error.

If msecs is -1, this function will not time out.

bool QLlcpSocket::waitForDisconnected ( int msecs = 30000 ) [virtual]

Waits until the socket is disconnected, up to msecs milliseconds. If the connection has been disconnected, this function returns true; otherwise it returns false. In the case where it returns false, you can call error() to determine the cause of the error.

If msecs is -1, this function will not time out.

bool QLlcpSocket::waitForReadyRead ( int msecs = 30000 ) [virtual]

Reimplemented from QIODevice::waitForReadyRead().

qint64 QLlcpSocket::writeDatagram ( const char * data, qint64 size )

Sends the datagram at data of size size to the service that this socket is connected to. Returns the number of bytes sent on success; otherwise return -1;

qint64 QLlcpSocket::writeDatagram ( const char * data, qint64 size, QNearFieldTarget * target, quint8 port )

Sends the datagram at data of size size to the service identified by the URI port on target. Returns the number of bytes sent on success; otherwise returns -1.

See also readDatagram().

qint64 QLlcpSocket::writeDatagram ( const QByteArray & datagram )

This is an overloaded function.

Sends the datagram datagram to the service that this socket is connected to.

qint64 QLlcpSocket::writeDatagram ( const QByteArray & datagram, QNearFieldTarget * target, quint8 port )

This is an overloaded function.

Sends the datagram datagram to the service identified by the URI port on target.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.