код php
<?php
$socket = stream_socket_server("tcp://127.0.0.1:4532", $errno, $errstr);
echo $errno . $errstr;
while ($connect = stream_socket_accept($socket, -1)) {
fread($connect);
fclose($connect);
echo "done";
}
fclose($socket);
?>
код QT C++ main.cpp
#include <QCoreApplication>
#include <QHostAddress>
#include <QTcpSocket>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QScopedPointer<QTcpSocket> socket(new QTcpSocket());
socket->connectToHost(QHostAddress::LocalHost, 4532);
if(socket->waitForConnected(5000) == false) return -1;
socket->write("12321");
return a.exec();
}
код QT C++ файл.pro
QT -= gui
QT += network
CONFIG += c++11 console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += \
main.cpp
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target