Commit 47c74e09 authored by Hobnob's avatar Hobnob

cross thread magic

parent 7a48403a
......@@ -8,9 +8,12 @@
#include <stdio.h>
#include <iostream>
#include <thread>
#include <vector>
#pragma comment(lib, "Ws2_32.lib")
std::vector<std::string> Messages;
// Override base class with your custom functionality
class Example : public olc::PixelGameEngine
{
......@@ -30,12 +33,17 @@ public:
bool OnUserUpdate(float fElapsedTime) override
{
DrawString(olc::vi2d(10, 10), "Hello World", olc::Pixel(255, 255, 255), 1);
int I = 0;
for (auto str : Messages)
{
I = I + 10;
DrawString(olc::vi2d(10, I), str, olc::Pixel(255, 255, 255), 1);
}
return true;
}
};
void DoSocket()
{
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
......@@ -105,15 +113,7 @@ void DoSocket()
if (iResult > 0) {
printf("Bytes received: %d\n", iResult);
std::cout << recvbuf << std::endl;
// Echo the buffer back to the sender
//iSendResult = send(ClientSocket, recvbuf, iResult, 0);
//if (iSendResult == SOCKET_ERROR) {
// printf("send failed: %d\n", WSAGetLastError());
// closesocket(ClientSocket);
// WSACleanup();
// return;
//}
//printf("Bytes sent: %d\n", iSendResult);
Messages.push_back(recvbuf);
}
else if (iResult == 0)
printf("Connection closing...\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment