Current location - Quotes Website - Collection of slogans - The Qt Socket network programming server prompts qiodevice:: read (qtcpsocket): the device is not turned on, but the connection with the client is successful.
The Qt Socket network programming server prompts qiodevice:: read (qtcpsocket): the device is not turned on, but the connection with the client is successful.
This is caused by the incorrect file path, and the solution is as follows:

1 First, the configuration of pro file: Qt network function needs to add network library to pro file.

2. The method code for establishing 2.QTcpServer server is shown in the following figure.

3. When there is a new client connection, QTcpServer will send out the signal method code of QTcpServer::newConnection.

4. The client is the active connector, and directly establishes the QTcpSocket code without listening.

5. Finally, connect the designated ip and port through connectToHost, and connect the signal of successful socket connection to the corresponding slot. When the connection is successful, the user-defined marker position can be set to true.