Added simple TCP socket server to handle requests and TCP socket client to test and measure.

This commit is contained in:
ftc
2023-02-14 22:48:18 +03:00
commit 09457cb6be
9 changed files with 535 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
#ifndef SYNCHRONOUS_SOCKET_HEADER_FILE_INCLUDED
#define SYNCHRONOUS_SOCKET_HEADER_FILE_INCLUDED
#include <string>
using namespace std;
class SynchronousSocket
{
private:
const int TIMEOUT = 10; // in seconds
protected:
// собственно сокет
int socket;
public:
SynchronousSocket();
// Используется для проброса уже готового сокета и работы с ним
void Init(int s);
bool IsConnected();
virtual void Connect(string host, int port);
virtual void Send(const string &data);
virtual string Receive(int amount);
void Disconnect();
string ReceiveMessage();
void SendMessage(const string &m);
};
#endif