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
tcpsocket.h
Go to the documentation of this file.
1
// Copyright (C) 2024 Jarek Kobus
2
// Copyright (C) 2024 The Qt Company Ltd.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5
#
ifndef
TASKING_TCPSOCKET_H
6
#
define
TASKING_TCPSOCKET_H
7
8
#
include
"tasking_global.h"
9
10
//
11
// W A R N I N G
12
// -------------
13
//
14
// This file is not part of the Qt API. It exists purely as an
15
// implementation detail. This header file may change from version to
16
// version without notice, or even be removed.
17
//
18
// We mean it.
19
//
20
21
#
include
"tasktree.h"
22
23
#
include
<
QtNetwork
/
QTcpSocket
>
24
25
#
include
<
memory
>
26
27
QT_BEGIN_NAMESPACE
28
29
namespace
Tasking
{
30
31
// This class introduces the dependency to Qt::Network, otherwise Tasking namespace
32
// is independent on Qt::Network.
33
// Possibly, it could be placed inside Qt::Network library, as a wrapper around QTcpSocket.
34
35
class
TASKING_EXPORT
TcpSocket
final
:
public
QObject
36
{
37
Q_OBJECT
38
39
public
:
40
~
TcpSocket
();
41
void
setAddress
(
const
QHostAddress &address) { m_address = address; }
42
void
setPort
(quint16 port) { m_port = port; }
43
void
setWriteData
(
const
QByteArray &data) { m_writeData = data; }
44
QTcpSocket
*
socket
()
const
{
return
m_socket.get(); }
45
void
start
();
46
47
Q_SIGNALS
:
48
void
started
();
49
void
done
(
DoneResult
result);
50
51
private
:
52
QHostAddress m_address;
53
quint16 m_port = 0;
54
QByteArray m_writeData;
55
std::unique_ptr<QTcpSocket> m_socket;
56
QAbstractSocket::SocketError m_error =
QAbstractSocket
::
UnknownSocketError
;
57
};
58
59
using
TcpSocketTask
=
SimpleCustomTask
<
TcpSocket
>;
60
61
}
// namespace Tasking
62
63
QT_END_NAMESPACE
64
65
#
endif
// TASKING_TCPSOCKET_H
Tasking::TcpSocket::done
void done(DoneResult result)
Tasking::TcpSocket::setAddress
void setAddress(const QHostAddress &address)
Definition
tcpsocket.h:41
Tasking::TcpSocket::setWriteData
void setWriteData(const QByteArray &data)
Definition
tcpsocket.h:43
Tasking::TcpSocket::setPort
void setPort(quint16 port)
Definition
tcpsocket.h:42
Tasking::TcpSocket::start
void start()
Definition
tcpsocket.cpp:11
Tasking::TcpSocket::~TcpSocket
~TcpSocket()
Definition
tcpsocket.cpp:47
Tasking::TcpSocket::socket
QTcpSocket * socket() const
Definition
tcpsocket.h:44
QPlatformGraphicsBufferHelper
\inmodule QtGui
Tasking
\inmodule TaskingSolution
Definition
concurrentcall.h:25
Tasking::DoneResult
DoneResult
Definition
tasktree.h:73
Tasking::DoneResult::Error
@ Error
Definition
tasktree.h:75
TASKING_EXPORT
#define TASKING_EXPORT
Definition
tasking_global.h:21
qtbase
src
assets
downloader
tasking
tcpsocket.h
Generated on
for Qt by
1.14.0