Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
tcpwait.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QTcpSocket>
5
7{
8 QTcpSocket socket;
9 socket.connectToHost("localhost", 1025);
10
11//! [0]
12 int numRead = 0, numReadTotal = 0;
13 char buffer[50];
14
15 forever {
16 numRead = socket.read(buffer, 50);
17
18 // do whatever with array
19
20 numReadTotal += numRead;
21 if (numRead == 0 && !socket.waitForReadyRead())
22 break;
23 }
24//! [0]
25 return numReadTotal;
26}
int test_tcpwait()
Definition tcpwait.cpp:6