Networking

Qt provides the QFtp and QHttp classes for working with FTP and HTTP. These protocols are easy to use for downloading and uploading files and, in the case of HTTP, for sending requests to web servers and retrieving the results.

Qt's QFtp and QHttp classes are built on the lower-level QSocket class, which provides a TCP socket. TCP operates in terms of data streams transmitted between network nodes. QSocket is in turn implemented on top of QSocketDevice, a thin wrapper around the platform-specific network APIs. The QSocketDevice class supports both TCP and UDP.

In this chapter, we will learn how to use the four classes mentioned above and other closely related classes, like QServerSocket and QSocketNotifier. We will also cover uploading and downloading files and how to use a web form programmatically. We will use TCP in a server application and in a corresponding client application. Similarly, we will use UDP in a sender application and in a corresponding receiver application. The coverage of QFtp and QHttp should be accessible to anyone, but the coverage of QSocket and especially QSocketDevice does assume some networking experience.

Категории