QTcpSocket socket; int fd = open("/path/to/socket", O_RDWR); socket.setSocketDescriptor(fd);
QTcpServer server; server.listen(QHostAddress::Any, 9999); QObject::connect(&server, &QTcpServer::newConnection, []() { QTcpServer* server = qobject_castIn this example, a QTcpServer is created and starts listening on all available network interfaces on port 9999. When a new client connection is established, setSocketDescriptor is used to associate the connection with STDIN_FILENO, which is the file descriptor for standard input. Package library: Qt, a C++ cross-platform application framework.(sender()); QTcpSocket* socket = server->nextPendingConnection(); socket->setSocketDescriptor(STDIN_FILENO); });