Qt例程之tcp socket

tripserver

The QTcpSocket class provides a TCP socket.

TCP (Transmission Control Protocol) is a reliable, stream-oriented, connection-oriented transport protocol.
It is especially well suited for continuous transmission of data.
傳輸控制協議是可靠的,流式,連接的傳輸協議,適合於連續傳輸的數據

bool QTcpServer::listen(const QHostAddress & address = QHostAddress::Any, quint16 port = 0)

Tells the server to listen for incoming connections on address address and port port. If port is 0,
a port is chosen automatically. If address is QHostAddress::Any, the server will listen on all network interfaces.
//告訴服務器監聽來的連接在地址和端口,如果端口是0,端口是自動選擇的,如果地址是QHostAddress::Any,服務器將監聽所有網絡接口

bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState socketState = ConnectedState, OpenMode openMode = ReadWrite)
Initializes QAbstractSocket with the native socket descriptor socketDescriptor. Returns true if socketDescriptor is accepted as a valid socket descriptor;
otherwise returns false. The socket is opened in the mode specified by openMode, and enters the socket state specified by socketState.
//使用原始的socket描述符 初始化QAbstractSocket,如果socketDescriptor是有效的socket描述符,返回真.socket由指定的模式openMode打開,進入socketState
指定的狀態.

qint64 QAbstractSocket::bytesAvailable() const
Reimplemented from QIODevice::bytesAvailable().
Returns the number of incoming bytes that are waiting to be read.
//返回等待讀的到來的字節數,

void QAbstractSocket::close()
Reimplemented from QIODevice::close().
Closes the I/O device for the socket, disconnects
the socket’s connection with the host, closes the socket, and resets the name, address, port number and underlying socket descriptor.
//關閉爲socket的i/o設備,斷開與host的socket連接,關閉socket。復位名字,地址,端口號,底層的socket描述

tripplanner

The QProgressBar widget provides a horizontal or vertical progress bar.
//水平和垂直的進度條

void QAbstractSocket::connectToHost(const QString & hostName, quint16 port, OpenMode openMode = ReadWrite)
Attempts to make a connection to hostName on the given port.

QString QIODevice::errorString() const
Returns a human-readable description of the last device error that occurred.
//返回可讀的 最後設備錯誤發生 描述

QIODevice * QDataStream::device() const
Returns the I/O device currently set, or 0 if no device is currently set.
//返回當前設置的i/o設備

void QAbstractSocket::connected()
This signal is emitted after connectToHost() has been called and a connection has been successfully established.
調用connectToHost()之後,這個信號被髮射,之後連接被成功建立

void QAbstractSocket::disconnected()
This signal is emitted when the socket has been disconnected.
//socket斷開後,此信號發射

void QIODevice::readyRead()
This signal is emitted once every time new data is available for reading from the device. It will only be emitted again once new data is available,
//每次新數據可以從設備讀的話,就發射此信號,一旦新數據可用,就繼續發射
such as when a new payload of network data has arrived on your network socket, or when a new block of data has been appended to your device.
//如網絡數據的新載荷到達你的網絡socket

void QAbstractSocket::error(QAbstractSocket::SocketError socketError)
This signal is emitted after an error occurred. The socketError parameter describes the type of error that occurred.
當錯誤發生後,此信號發射.錯誤參數描述了發生錯誤的類型

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章