近日要用Qt设计路灯节能监控系统的上位机,用到QTcpSocket类,参考文档英文的,看起来不方便,按学习笔记的方式,归纳如下:
1. enum QAbstractSocket::NetworkLayerProtocol
This enum describes the network layer protocol values used in Qt.
Constant
Value
Description
QAbstractSocket::IPv4Protocol
QAbstractSocket::IPv6Protocol
QAbstractSocket::UnknownNetworkLayerProtocol
Other than IPv4 and IPv6
列出了Qt使用的网络层次协议,如IP4,IP6.
2.enum QIODevice::OpenModeFlag
flags QIODevice::OpenMode
This enum is used with
open
() to describe the mode in which a device is opened. It is also returned by
openMode
().
Constant
Value
Description
QIODevice::NotOpen
0x0000
The device is not open.
QIODevice::ReadOnly
0x0001
The device is open for reading.
QIODevice::WriteOnly
0x0002
The device is open for writing.
QIODevice::ReadWrite
ReadOnly | WriteOnly
The device is open for reading and writing.
QIODevice::Append
0x0004
The device is opened in append mode, so that all data is written to the end of the file.
QIODevice::Truncate
0x0008
If possible, the device is truncated before it is opened. All earlier contents of the device are lost.
QIODevice::Text
0x0010
When reading, the end-of-line terminators are translated to '\n'. When writing, the end-of-line terminators are translated to the local encoding, for example '\r\n' for Win32.
QIODevice::Unbuffered
0x0020
Any buffer in the device is bypassed.
QAbstractSocket::ConnectionRefusedError
The connection was refused by the peer (or timed out).
QAbstractSocket::RemoteHostClosedError
The remote host closed the connection. Note that the client socket (i.e., this socket) will be closed after the remote close notification has been sent.
QAbstractSocket::HostNotFoundError
The host address was not found.
QAbstractSocket::SocketAccessError
The socket operation failed because the application lacked the required privileges.
QAbstractSocket::SocketResourceError
The local system ran out of resources (e.g., too many sockets).
QAbstractSocket::SocketTimeoutError
The socket operation timed out.
QAbstractSocket::DatagramTooLargeError
The datagram was larger than the operating system's limit (which can be as low as 8192 bytes).
QAbstractSocket::NetworkError
An error occurred with the network (e.g., the network cable was accidentally plugged out).
QAbstractSocket::AddressInUseError
The address specified to
QUdpSocket::bind
() is already in use and was set to be exclusive.
QAbstractSocket::SocketAddressNotAvailableError
The address specified to
QUdpSocket::bind
() does not belong to the host.
QAbstractSocket::UnsupportedSocketOperationError
The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support).
QAbstractSocket::ProxyAuthenticationRequiredError
The socket is using a proxy, and the proxy requires authentication.
QAbstractSocket::SslHandshakeFailedError
The SSL/TLS handshake failed, so the connection was closed (only used in
QSslSocket
)
QAbstractSocket::UnfinishedSocketOperationError
Used by QAbstractSocketEngine only, The last operation attempted has not finished yet (still in progress in the background).
QAbstractSocket::ProxyConnectionRefusedError
Could not contact the proxy server because the connection to that server was denied
QAbstractSocket::ProxyConnectionClosedError
The connection to the proxy server was closed unexpectedly (before the connection to the final peer was established)
QAbstractSocket::ProxyConnectionTimeoutError
The connection to the proxy server timed out or the proxy server stopped responding in the authentication phase.
QAbstractSocket::ProxyNotFoundError
The proxy address set with
setProxy
() (or the application proxy) was not found.
QAbstractSocket::ProxyProtocolError
The connection negotiation with the proxy server because the response from the proxy server could not be understood.
QAbstractSocket::UnknownSocketError
An unidentified error occurred.
QAbstractSocket::ClosingState
The socket is about to close (data may still be waiting to be written).
QAbstractSocket::ListeningState
For internal use only.