1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | //#define QTCPSOCKET_DEBUG |
5 | |
6 | /*! |
7 | \class QTcpSocket |
8 | |
9 | \brief The QTcpSocket class provides a TCP socket. |
10 | |
11 | \reentrant |
12 | \ingroup network |
13 | \inmodule QtNetwork |
14 | |
15 | TCP (Transmission Control Protocol) is a reliable, |
16 | stream-oriented, connection-oriented transport protocol. It is |
17 | especially well suited for continuous transmission of data. |
18 | |
19 | QTcpSocket is a convenience subclass of QAbstractSocket that |
20 | allows you to establish a TCP connection and transfer streams of |
21 | data. See the QAbstractSocket documentation for details. |
22 | |
23 | \note TCP sockets cannot be opened in QIODevice::Unbuffered mode. |
24 | |
25 | \sa QTcpServer, QUdpSocket, QNetworkAccessManager, |
26 | {Fortune Server}, {Fortune Client}, |
27 | {Threaded Fortune Server}, {Blocking Fortune Client}, |
28 | {Torrent Example} |
29 | */ |
30 | |
31 | #include "qtcpsocket.h" |
32 | #include "qtcpsocket_p.h" |
33 | #include "qlist.h" |
34 | #include "qhostaddress.h" |
35 | |
36 | QT_BEGIN_NAMESPACE |
37 | |
38 | /*! |
39 | Creates a QTcpSocket object in state \c UnconnectedState. |
40 | |
41 | \a parent is passed on to the QObject constructor. |
42 | |
43 | \sa socketType() |
44 | */ |
45 | QTcpSocket::QTcpSocket(QObject *parent) |
46 | : QAbstractSocket(TcpSocket, *new QTcpSocketPrivate, parent) |
47 | { |
48 | #if defined(QTCPSOCKET_DEBUG) |
49 | qDebug("QTcpSocket::QTcpSocket()" ); |
50 | #endif |
51 | d_func()->isBuffered = true; |
52 | } |
53 | |
54 | /*! |
55 | Destroys the socket, closing the connection if necessary. |
56 | |
57 | \sa close() |
58 | */ |
59 | |
60 | QTcpSocket::~QTcpSocket() |
61 | { |
62 | #if defined(QTCPSOCKET_DEBUG) |
63 | qDebug("QTcpSocket::~QTcpSocket()" ); |
64 | #endif |
65 | } |
66 | |
67 | /*! |
68 | \internal |
69 | */ |
70 | QTcpSocket::QTcpSocket(QTcpSocketPrivate &dd, QObject *parent) |
71 | : QAbstractSocket(TcpSocket, dd, parent) |
72 | { |
73 | d_func()->isBuffered = true; |
74 | } |
75 | |
76 | /*! |
77 | \internal |
78 | */ |
79 | QTcpSocket::QTcpSocket(QAbstractSocket::SocketType socketType, |
80 | QTcpSocketPrivate &dd, QObject *parent) |
81 | : QAbstractSocket(socketType, dd, parent) |
82 | { |
83 | } |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #include "moc_qtcpsocket.cpp" |
88 | |