Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
bfs/breadcrumbs/include/DataSyncThread.hpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
51 lines (41 sloc)
1.04 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef DATA_SYNC_THREAD_HPP | |
#define DATA_SYNC_THREAD_HPP | |
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <winsock2.h> | |
#include <ws2tcpip.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include "Attribute.hpp" | |
#include "CMakeConfig.h" | |
// Need to link with Ws2_32.lib, Mswsock.lib, and Advapi32.lib | |
#pragma comment (lib, "Ws2_32.lib") | |
#pragma comment (lib, "Mswsock.lib") | |
#pragma comment (lib, "AdvApi32.lib") | |
/* | |
This class contains the thread for communicating back and forth along a socket to sync attributes | |
*/ | |
class DataSyncThread | |
{ | |
private: | |
SOCKET sock; | |
HANDLE hThread; | |
DWORD dwThreadId; | |
bool continueThread = false; | |
public: | |
DataSyncThread(SOCKET s) { sock = s; }; | |
// Synchronous functions | |
void threadRuntime(); | |
static DWORD threadInit(LPVOID pThreadArgs) | |
{ | |
DataSyncThread* pDataSyncThread = (DataSyncThread*)pThreadArgs; | |
pDataSyncThread->threadRuntime(); | |
return NULL; | |
} | |
int recvBytes(void* buffer, size_t numBytes); | |
// Async control | |
void startComms(); | |
bool stopComms(); | |
int connectToAlgorithm(char* serverName); | |
}; | |
#endif |