summaryrefslogtreecommitdiff
path: root/doc/src/connectivity.qdoc
blob: c7deaec3d3ef9fe72d34a75f51864581ae49c32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page topics-network-connectivity.html
\title Networking and Connectivity
\brief Qt's network and connectivity features

Qt provides classes for both high-level and low-level network communication,
classes for web integration, and classes for interprocess communication.

For high-level network traffic, \l{Qt Network} provides an abstraction layer
over the operations used, showing only high-level classes and functions. Qt
Network can also handle lower level protocols like TCP and UDP. Classes like
QTcpSocket and QUdpSocket enable the developer to send and receive messages
using the TCP or UDP protocol.Name resolution is done with QHostInfo. QHostInfo
is called before creating a network connection with QTcpSocket or QUdpSocket.
Filtering and redistributing network traffic via proxies can handled by the
QNetWorkProxy class.

Qt Network also provides the \l{Bearer Management} API. It has functions that
can start or stop network interfaces and roam between access points. It does
however not take care of the network configurations itself. The platform needs
to take care of that.

\l{Qt WebKit} offers a web browser engine that makes it possible to use web
content in your application. \l{Qt WebKit} can render HTML, XHTML,
and SVG documents, and execute Javascript.

Qt also offers functionalities for \e{inter-process communication} (IPC). The
class QProcess is used to start external programs. \l{Qt D-Bus} provides support
for D-Bus, an interprocess communication and remoteprocedure calling mechanism.
It mostly communicates via a central server application, called a bus. However,
it is also possible to let applications communicate directly with each other.
QSharedMemory provides access to a shared memory segment by multiple threads
and processes. It is however also possible for a single process to
exclusively lock that shared memory.

\section1 Network Communication

Qt supports a wide range of network communication, with a focus on HTTP, TCP,
and UDP.

At the HTTP level, the \l{Qt Network} module offers the network access API,
which consists mainly of QNetworkRequest, QNetworkAccessManager, and
QNetworkReply. Put simply, the QNetworkRequest resembles an HTTP request, which
gets passed to the QNetworkAccessManager to send the request on the wire; this
class returns a QNetworkReply, which enables parsing the HTTP reply. The network
access API uses the socket classes mentioned below (for TCP and SSL) internally.

For communication at the socket level, QTcpSocket, QUdpSocket and QSslSocket
should be used. These classes offer a synchronous API through the waitFor*
methods as well as an asynchronous API; if possible (i.e. if the event loop is
running), the asynchronous API should always be preferred. Qt also offers
QTcpServer to enable the server-side part of a TCP communication. Please note
that there is no HTTP server class in Qt.

For secure communication via SSL, Qt Network offers a wide range of classes
alongside the central QSslSocket, e.g. QSslCertificate, QSslConfiguration and
QSslError. The only supported backend for SSL in Qt is OpenSSL, which needs to
be installed separately.

For mobile devices, Qt Network offers the \l{Bearer Management}{bearer
management} API to track the status of a connection (e.g. getting notified about
online/offline status or whether Wifi or 3G is used).

Qt also offers HTTP support in QML by either using HTTP explicitly via
XmlHttpRequest, or by transparently using HTTP URLs in e.g. Image sources.

Related Topics:
\list
\li \l{Qt Network} - module documentation
    \list
        \li \l {Network Programming API}
        \li \l {Network Programming with Qt}
        \li \l {Qt Network C++ Classes}
        \li \l {Secure Sockets Layer (SSL) Classes}
        \li \l {Bearer Management}
    \endlist
\li \l {Resource Loading and Network Transparency} - network and URL transparency in QML
\endlist

\section1 WebSockets

An alternative to direct TCP or HTTP communication is to use the WebSocket
protocol (\l{http://tools.ietf.org/html/rfc6455}{RFC 6455}). It is a
two-way communication protocol on top of the TCP protocol to utilize existing
web infrastructure without having to create additional client-server based
communication. The \l{Qt WebSockets} module provides both a QML and C++ API,
in addition to several examples to demonstrate its use.

\section1 World Wide Web Support

Qt makes it easy to embed web content into your Qt application using features of
the Qt WebKit layout engine. The Qt WebKit module equips Qt with support for a
broad range of standard web technologies that make it possible to embed HTML
content styled with CSS and scripted with JavaScript into your Qt application.
\l{Qt WebKit} facilitates both integration with traditional QWidget based desktop
applications as well as embedding into Qt Quick QML applications.

For more information see \l {Integrating Web Content}.

\section1 Inter-Process Communication

Qt provides several ways to implement Inter-Process Communication
(IPC) in Qt applications.

The cross-platform \l{Qt Network} module provides classes that make
network programming portable and easy. It offers high-level
classes (e.g., QNetworkAccessManager, QFtp) that communicate using
specific application-level protocols, and lower-level classes
(e.g., QTcpSocket, QTcpServer, QSslSocket) for implementing
protocols.

The cross-platform shared memory class, QSharedMemory, provides
access to the operating system's shared memory implementation.
It allows safe access to shared memory segments by multiple threads
and processes. Additionally, QSystemSemaphore can be used to control
access to resources shared by the system, as well as to communicate
between processes.

The \l{Qt D-Bus} module is a cross-platform library you can use to
implement IPC using the D-Bus protocol. It extends Qt's
\l{Signals & Slots}{signals and slots} mechanism to the IPC
level, allowing a signal emitted by one process to be connected to
a slot in another process.

The cross-platform class \l{QProcess} can be used to start external
programs as child processes, and to communicate with them. It provides
an API for monitoring and controlling the state of the child
process. QProcess gives access to the input/output channels of child
process by inheriting from QIODevice.

The \l{QLocalSocket} class provides a local socket. On Windows this is
a named pipe and on Unix this is a local domain socket.
The \l{QLocalServer} class provides a local socket based server. This
class makes it possible to accept incoming local socket connections.

Related Topics:

\list
\li \l {Qt D-Bus} - module documentation
    \list
    \li \l {Using Qt D-Bus Adaptors}
    \li \l {Declaring Signals in D-Bus Adaptors}
    \li \l {Declaring Slots in D-Bus Adaptors}
    \li \l {The Qt D-Bus Type System}
    \li \l {Qt D-Bus XML compiler (qdbusxml2cpp)}
    \endlist
\li \l {QLocalSocket}
\li \l {QSharedMemory}
\endlist

\section1 Serial Port Communication

The \l{Qt Serial Port} module provides a C++ API for communicating
through serial ports, using the RS-232 standard. It works with physical
ports and also with drivers that emulate these ports. Examples of serial
port emulators include virtual COM ports, com0com emulators, and the
Bluetooth SPP.

This module is designed to make serial port programming easier and portable.
As of Qt 5.2, it is supported on \l{Qt for Windows}{Windows}, \l{Qt for OS X}{OS X},
and \l{Qt for Linux/X11}{Linux}.

Related topics:
\list
\li \l {Qt Serial Port} - module documentation
\li \l {Qt Serial Port C++ Classes}
\endlist

\section1 Bluetooth Communication

The \l{Qt Bluetooth} module provides both C++ and QML APIs for the
short-range (less than 100 meters) wireless protocol developed by the
\l{Bluetooth SIG}{Bluetooth Special Interest Group}. It provides
classic Bluetooth and Bluetooth Low Energy features.

Related topics:
\list
\li \l {Qt Bluetooth} - module documentation
    \list
    \li \l {Qt Bluetooth Overview} {Bluetooth Classic}
    \li \l {Bluetooth Low Energy Overview} {Bluetooth Low Energy}
    \li \l {Qt Bluetooth C++ Classes}
    \li \l {Qt Bluetooth QML Types}
    \endlist
\endlist


\section1 Near Field Communication

The \l{Qt NFC} module provides both C++ and QML APIs for the extremely
short-range (less than 20 centimeters) wireless protocol developed by the
\l{http://www.nfc-forum.org}{NFC Forum}.

Related topics:
\list
\li \l {Qt NFC} - module documentation
    \list
    \li \l {Qt NFC Overview}
    \li \l {Qt NFC C++ Classes}
    \li \l {Qt NFC QML Types}
    \endlist
\endlist

*/