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

来源:互联网 发布:什么是软件质量 编辑:程序博客网 时间:2024/05/29 17:35

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

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

  1. enum QAbstractSocket::NetworkLayerProtocol

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

ConstantValueDescriptionQAbstractSocket::IPv4Protocol0IPv4QAbstractSocket::IPv6Protocol1IPv6QAbstractSocket::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().

ConstantValueDescriptionQIODevice::NotOpen0x0000The device is not open.QIODevice::ReadOnly0x0001The device is open for reading.QIODevice::WriteOnly0x0002The device is open for writing.QIODevice::ReadWriteReadOnly | WriteOnlyThe device is open for reading and writing.QIODevice::Append0x0004The device is opened in append mode, so that all data is written to the end of the file.QIODevice::Truncate0x0008If possible, the device is truncated before it is opened. All earlier contents of the device are lost.QIODevice::Text0x0010When 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::Unbuffered0x0020Any buffer in the device is bypassed.

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

3.enum QAbstractSocket::SocketError

This enum describes the socket errors that can occur.

ConstantValueDescriptionQAbstractSocket::ConnectionRefusedError0The connection was refused by the peer (or timed out).QAbstractSocket::RemoteHostClosedError1The 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::HostNotFoundError2The host address was not found.QAbstractSocket::SocketAccessError3The socket operation failed because the application lacked the required privileges.QAbstractSocket::SocketResourceError4The local system ran out of resources (e.g., too many sockets).QAbstractSocket::SocketTimeoutError5The socket operation timed out.QAbstractSocket::DatagramTooLargeError6The datagram was larger than the operating system's limit (which can be as low as 8192 bytes).QAbstractSocket::NetworkError7An error occurred with the network (e.g., the network cable was accidentally plugged out).QAbstractSocket::AddressInUseError8The address specified to QUdpSocket::bind() is already in use and was set to be exclusive.QAbstractSocket::SocketAddressNotAvailableError9The address specified to QUdpSocket::bind() does not belong to the host.QAbstractSocket::UnsupportedSocketOperationError10The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support).QAbstractSocket::ProxyAuthenticationRequiredError12The socket is using a proxy, and the proxy requires authentication.QAbstractSocket::SslHandshakeFailedError13The SSL/TLS handshake failed, so the connection was closed (only used in QSslSocket)QAbstractSocket::UnfinishedSocketOperationError11Used by QAbstractSocketEngine only, The last operation attempted has not finished yet (still in progress in the background).QAbstractSocket::ProxyConnectionRefusedError14Could not contact the proxy server because the connection to that server was deniedQAbstractSocket::ProxyConnectionClosedError15The connection to the proxy server was closed unexpectedly (before the connection to the final peer was established)QAbstractSocket::ProxyConnectionTimeoutError16The connection to the proxy server timed out or the proxy server stopped responding in the authentication phase.QAbstractSocket::ProxyNotFoundError17The proxy address set with setProxy() (or the application proxy) was not found.QAbstractSocket::ProxyProtocolError18The 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.

ConstantValueDescriptionQAbstractSocket::UnconnectedState0The socket is not connected.QAbstractSocket::HostLookupState1The socket is performing a host name lookup.QAbstractSocket::ConnectingState2The socket has started establishing a connection.QAbstractSocket::ConnectedState3A connection is established.QAbstractSocket::BoundState4The socket is bound to an address and port (for servers).QAbstractSocket::ClosingState6The socket is about to close (data may still be waiting to be written).QAbstractSocket::ListeningState5For internal use only.

列出了套接字的连接状态

5.enum QAbstractSocket::SocketType

This enum describes the transport layer protocol.

ConstantValueDescriptionQAbstractSocket::TcpSocket0TCPQAbstractSocket::UdpSocket1UDPQAbstractSocket::UnknownSocketType-1Other than TCP and UDP

See also QAbstractSocket::socketType().

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

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

原创粉丝点击