QTcpSocket* socket = new QTcpSocket(); socket->connectToHost("127.0.0.1", 8080); socket->write("Hello World"); socket->close();
void MyClass::disconnect() { socket->close(); }This example is part of a larger class and shows a function that simply closes the socket object. QTcpSocket is part of the Qt Network module.