Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QTcpSocket Class Reference

Inheritance diagram for QTcpSocket:

QAbstractSocket QIODevice QObject QSslSocket

List of all members.


Detailed Description

The QTcpSocket class provides a TCP socket.

network

TCP (Transmission Control Protocol) is a reliable, stream-oriented, connection-oriented transport protocol. It is especially well suited for continuous transmission of data.

QTcpSocket is a convenience subclass of QAbstractSocket that allows you to establish a TCP connection and transfer streams of data. See the QAbstractSocket documentation for details.

{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode.

See also:
QTcpServer, QUdpSocket, QFtp, QHttp, {Fortune Server Example}, {Fortune Client Example}, {Threaded Fortune Server Example}, {Blocking Fortune Client Example}, {Loopback Example}, {Torrent Example}

Definition at line 57 of file qtcpsocket.h.


Public Types

enum  NetworkLayerProtocol { IPv4Protocol, IPv6Protocol, UnknownNetworkLayerProtocol = -1 }
enum  OpenModeFlag {
  NotOpen = 0x0000, ReadOnly = 0x0001, WriteOnly = 0x0002, ReadWrite = ReadOnly | WriteOnly,
  Append = 0x0004, Truncate = 0x0008, Text = 0x0010, Unbuffered = 0x0020
}
enum  SocketError {
  ConnectionRefusedError, RemoteHostClosedError, HostNotFoundError, SocketAccessError,
  SocketResourceError, SocketTimeoutError, DatagramTooLargeError, NetworkError,
  AddressInUseError, SocketAddressNotAvailableError, UnsupportedSocketOperationError, UnfinishedSocketOperationError,
  ProxyAuthenticationRequiredError, SslHandshakeFailedError, UnknownSocketError = -1
}
enum  SocketState {
  UnconnectedState, HostLookupState, ConnectingState, ConnectedState,
  BoundState, ListeningState, ClosingState
}
enum  SocketType { TcpSocket, UdpSocket, UnknownSocketType = -1 }

Public Slots

void deleteLater ()

Signals

void aboutToClose ()
void bytesWritten (qint64 bytes)
void connected ()
void destroyed (QObject *=0)
void disconnected ()
void error (QAbstractSocket::SocketError)
void hostFound ()
void proxyAuthenticationRequired (const QNetworkProxy &proxy, QAuthenticator *authenticator)
void readChannelFinished ()
void readyRead ()
void stateChanged (QAbstractSocket::SocketState)

Public Member Functions

void abort ()
bool atEnd () const
bool blockSignals (bool b)
qint64 bytesAvailable () const
qint64 bytesToWrite () const
bool canReadLine () const
const QObjectListchildren () const
void close ()
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
void connectToHost (const QHostAddress &address, quint16 port, OpenMode mode=ReadWrite)
void connectToHost (const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void disconnectFromHost ()
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
SocketError error () const
QString errorString () const
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
template<typename T>
findChild (const QString &aName=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &aName=QString()) const
bool flush ()
bool getChar (char *c)
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isOpen () const
bool isReadable () const
bool isSequential () const
bool isTextModeEnabled () const
bool isValid () const
bool isWidgetType () const
bool isWritable () const
void killTimer (int id)
QHostAddress localAddress () const
quint16 localPort () const
void moveToThread (QThread *thread)
QString objectName () const
virtual bool open (OpenMode mode)
OpenMode openMode () const
QObjectparent () const
QByteArray peek (qint64 maxlen)
qint64 peek (char *data, qint64 maxlen)
QHostAddress peerAddress () const
QString peerName () const
quint16 peerPort () const
virtual qint64 pos () const
QVariant property (const char *name) const
QNetworkProxy proxy () const
bool putChar (char c)
 QTcpSocket (QObject *parent=0)
QByteArray read (qint64 maxlen)
qint64 read (char *data, qint64 maxlen)
QByteArray readAll ()
qint64 readBufferSize () const
QByteArray readLine (qint64 maxlen=0)
qint64 readLine (char *data, qint64 maxlen)
void removeEventFilter (QObject *)
virtual bool reset ()
virtual bool seek (qint64 pos)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setProxy (const QNetworkProxy &networkProxy)
void setReadBufferSize (qint64 size)
bool setSocketDescriptor (int socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite)
void setTextModeEnabled (bool enabled)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
virtual qint64 size () const
int socketDescriptor () const
SocketType socketType () const
int startTimer (int interval)
SocketState state () const
QThreadthread () const
void ungetChar (char c)
QObjectUserData * userData (uint id) const
bool waitForBytesWritten (int msecs=30000)
bool waitForConnected (int msecs=30000)
bool waitForDisconnected (int msecs=30000)
bool waitForReadyRead (int msecs=30000)
qint64 write (const QByteArray &data)
qint64 write (const char *data, qint64 len)
virtual ~QTcpSocket ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Slots

void connectToHostImplementation (const QString &hostName, quint16 port, OpenMode mode=ReadWrite)
void disconnectFromHostImplementation ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
 QTcpSocket (QTcpSocketPrivate &dd, QObject *parent=0)
qint64 readData (char *data, qint64 maxlen)
qint64 readLineData (char *data, qint64 maxlen)
int receivers (const char *signal) const
QObjectsender () const
void setErrorString (const QString &errorString)
void setLocalAddress (const QHostAddress &address)
void setLocalPort (quint16 port)
void setOpenMode (OpenMode openMode)
void setPeerAddress (const QHostAddress &address)
void setPeerName (const QString &name)
void setPeerPort (quint16 port)
void setSocketError (SocketError socketError)
void setSocketState (SocketState state)
virtual void timerEvent (QTimerEvent *)
qint64 writeData (const char *data, qint64 len)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

QString objectName
 the name of this object

Friends

class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name=QString(), T dummy=0)
qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
 QObjectList
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index