From 3342cb76801f71c33b5c6b406154e4bf74e73e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DOTTEL=20Ga=C3=ABl?= Date: Mon, 25 Dec 2023 18:01:31 +0100 Subject: [PATCH] socket test --- .../DevPrograms/TestProgramComputer.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp index f4342a3ec..2d36a7356 100644 --- a/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp +++ b/SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramComputer.cpp @@ -147,6 +147,8 @@ //#include +#include +#include #include using std::cout; @@ -243,6 +245,25 @@ void TestProgramComputer::program(ProgramEnvironment& env, CancellableScope& sco BattleMenuDetector detector; cout << detector.detect(image) << endl; + 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