QtCraft API C++ classes QML types Handbook

QcTcpGoodbye Class

Ends a TCP connection so that the peer reads everything sent before (decision E-904). More...

Header: #include <network/QcTcpGoodbye.h>
Inherits: QObject

Static Public Members

void begin(QTcpSocket &socket, int lingerMs, bool peerLeft)
void finishLingering(int maxWaitMs = 1'000)
void release(std::unique_ptr<QTcpSocket> owned, int lingerMs, bool peerLeft)

Detailed Description

Closing at once with unread or later arriving data makes the system reset the connection, and a Windows peer throws away what it had not read yet: the reason of a Disconnect. So the goodbye

Lives as a child of its socket, in the socket's thread.

Member Function Documentation

[static] void QcTcpGoodbye::begin(QTcpSocket &socket, int lingerMs, bool peerLeft)

Starts the goodbye of a connected socket, once; the owner keeps the socket. Closes a socket that is not connected at once. lingerMs is the linger time, peerLeft tells that the peer said goodbye first.

[static] void QcTcpGoodbye::finishLingering(int maxWaitMs = 1'000)

Runs the calling thread's event loop until the sockets released in it ended their goodbye, at most maxWaitMs, and ends the rest; for a thread that is about to end, which would otherwise cut them off at once. Returns at once in a thread without.

[static] void QcTcpGoodbye::release(std::unique_ptr<QTcpSocket> owned, int lingerMs, bool peerLeft)

Takes owned over and starts its goodbye as begin() does with lingerMs and peerLeft: the socket deletes itself when the goodbye ended or when its thread ends.