part way through switch to cin parser
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <pthread.h>
|
||||
#include "util.hpp"
|
||||
|
||||
typedef void (*data_received_cb_t)(SOCKET client, array<char> data);
|
||||
|
||||
struct tcpserver {
|
||||
SOCKET sock;
|
||||
array<SOCKET> client_socks;
|
||||
int max_connections;
|
||||
addrinfo* addr;
|
||||
array<data_received_cb_t> cbs;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t connection_ended;
|
||||
pthread_cond_t stop_requested;
|
||||
};
|
||||
|
||||
bool create_server(tcpserver* server_out, const char* hostname, int port, int max_connections);
|
||||
void start_server(tcpserver& s);
|
||||
void stop_server(tcpserver& s);
|
||||
void send_data(tcpserver& s, SOCKET client, array<char> data);
|
||||
void register_recv_cb(tcpserver& s, data_received_cb_t cb);
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <cstdlib>
|
||||
#include <stdio.h>
|
||||
|
||||
#define min(a, b) ((a < b) ? a : b)
|
||||
#define max(a, b) ((a > b) ? a : b)
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
template<class T> struct array {
|
||||
@@ -15,4 +18,7 @@ template<class T> struct array {
|
||||
template<class T> void append(array<T>& a, T el);
|
||||
template<class T> T pop(array<T>& a);
|
||||
template<class T> void resize(array<T>& a, size_t new_cap);
|
||||
template<class T> void free(array<T>& a);
|
||||
bool read_file(array<char>* out, const char* filepath);
|
||||
array<char*> split_str(const char *s, char delimiter);
|
||||
array<char*> split_str(const char *s);
|
||||
|
||||
Reference in New Issue
Block a user