Skip to content

Commit

Permalink
socket test
Browse files Browse the repository at this point in the history
  • Loading branch information
pifopi committed Apr 25, 2024
1 parent 8cd38a1 commit 4af46c8
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@

//#include <opencv2/core.hpp>

#include <QTcpSocket>
#include <QDataStream>

#include <iostream>
using std::cout;
Expand Down Expand Up @@ -264,6 +266,26 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco
cout << detector.detect(image) << endl;
#endif

QTcpSocket socket;
socket.connectToHost("127.0.0.1", 18069);
socket.waitForConnected();

while (true) {
QDataStream outData(&socket);
outData << std::int32_t{ 42 };

socket.waitForReadyRead();
QDataStream inData(socket.readAll());
std::int32_t inValue;
inData >> inValue;

std::stringstream ss;
ss << "Received : " << inValue;
env.logger().log(ss.str());

std::this_thread::sleep_for(std::chrono::seconds(10));
}


#if 0
ImageRGB32 image("20231120-221849973351.png");
Expand Down

0 comments on commit 4af46c8

Please sign in to comment.