QT QAbstractSocket SocketError和 一些网络编程 用到的值

最近在一个QT程序上修改代码,基本上是遇到什么问题就查什么问题 下面是关于QAbstractSocket::SocketError值

和一些其他的值,还是很有用的

  1. enum QAbstractSocket::NetworkLayerProtocol

This enum describes the network layer protocol values used in Qt.

Constant Value Description
QAbstractSocket::IPv4Protocol 0IPv4
QAbstractSocket::IPv6Protocol 1IPv6
QAbstractSocket::UnknownNetworkLayerProtocol -1Other 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 0x0000The device is not open.
QIODevice::ReadOnly 0x0001The device is open for reading.
QIODevice::WriteOnly 0x0002The device is open for writing.
QIODevice::ReadWrite ReadOnly | WriteOnlyThe device is open for reading and writing.
QIODevice::Append 0x0004The device is opened in append mode, so that all data is written to the end of the file.
QIODevice::Truncate 0x0008If possible, the device is truncated before it is opened. All earlier contents of the device are lost.
QIODevice::Text 0x0010When 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 0x0020Any buffer in the device is bypassed.

列出了打开设备的状态。如设备未打开,以只读的方式打开,以写的方式打开。

3.enum QAbstractSocket::SocketError

This enum describes the socket errors that can occur.

Constant Value Description
QAbstractSocket::ConnectionRefusedError 0The connection was refused by the peer (or timed out).
QAbstractSocket::RemoteHostClosedError 1The 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 2The host address was not found.
QAbstractSocket::SocketAccessError 3The socket operation failed because the application lacked the required privileges.
QAbstractSocket::SocketResourceError 4The local system ran out of resources (e.g., too many sockets).
QAbstractSocket::SocketTimeoutError 5The socket operation timed out.
QAbstractSocket::DatagramTooLargeError 6The datagram was larger than the operating system's limit (which can be as low as 8192 bytes).
QAbstractSocket::NetworkError 7An error occurred with the network (e.g., the network cable was accidentally plugged out).
QAbstractSocket::AddressInUseError 8The address specified to QUdpSocket::bind() is already in use and was set to be exclusive.
QAbstractSocket::SocketAddressNotAvailableError 9The address specified to QUdpSocket::bind() does not belong to the host.
QAbstractSocket::UnsupportedSocketOperationError 10The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support).
QAbstractSocket::ProxyAuthenticationRequiredError 12The socket is using a proxy, and the proxy requires authentication.
QAbstractSocket::SslHandshakeFailedError 13The SSL/TLS handshake failed, so the connection was closed (only used in QSslSocket)
QAbstractSocket::UnfinishedSocketOperationError 11Used by QAbstractSocketEngine only, The last operation attempted has not finished yet (still in progress in the background).
QAbstractSocket::ProxyConnectionRefusedError 14Could not contact the proxy server because the connection to that server was denied
QAbstractSocket::ProxyConnectionClosedError 15The connection to the proxy server was closed unexpectedly (before the connection to the final peer was established)
QAbstractSocket::ProxyConnectionTimeoutError 16The connection to the proxy server timed out or the proxy server stopped responding in the authentication phase.
QAbstractSocket::ProxyNotFoundError 17The proxy address set with setProxy() (or the application proxy) was not found.
QAbstractSocket::ProxyProtocolError 18The connection negotiation with the proxy server because the response from the proxy server could not be understood.
QAbstractSocket::UnknownSocketError -1An unidentified error occurred.

列出了连接中可能发 生的错误,错误一一列在上表中。

4.enum QAbstractSocket::SocketState

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

Constant Value Description
QAbstractSocket::UnconnectedState 0The socket is not connected.
QAbstractSocket::HostLookupState 1The socket is performing a host name lookup.
QAbstractSocket::ConnectingState 2The socket has started establishing a connection.
QAbstractSocket::ConnectedState 3A connection is established.
QAbstractSocket::BoundState 4The socket is bound to an address and port (for servers).
QAbstractSocket::ClosingState 6The socket is about to close (data may still be waiting to be written).
QAbstractSocket::ListeningState 5For internal use only.

列出了套接字的连接状态

5.enum QAbstractSocket::SocketType

This enum describes the transport layer protocol.

Constant Value Description
QAbstractSocket::TcpSocket 0TCP
QAbstractSocket::UdpSocket 1UDP
QAbstractSocket::UnknownSocketType -1Other than TCP and UDP

See also QAbstractSocket::socketType().

列出了套接字的连接方式。

表里面的内容以后有空整理,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值