-
Notifications
You must be signed in to change notification settings - Fork 0
/
TCPClient.h
30 lines (24 loc) · 965 Bytes
/
TCPClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef INCLUDE_UTILITIES_TCPCLIENT
#define INCLUDE_UTILITIES_TCPCLIENT
#include "Common.h"
#include "AsyncList.h"
#include "TCPServer.h"
#include <SAL/Common.h>
#include <SAL/Thread.h>
#include <SAL/Socket.h>
/* forward declarations */
typedef struct TCPClient TCPClient;
typedef void (*TCPClient_OnServerDisconnect)(TCPClient* client, void* state);
typedef void (*TCPClient_OnReceive)(TCPClient* client, void* state, uint8* buffer, uint16 length);
struct TCPClient {
SAL_Socket* Server;
TCPClient_OnReceive ReceiveCallback;
TCPClient_OnServerDisconnect DisconnectCallback;
uint8 Buffer[MESSAGE_MAXSIZE];
uint16 BytesReceived;
void* State;
};
export TCPClient* TCPClient_Connect(int8* address, int8* port, TCPClient_OnReceive receiveCallback, TCPClient_OnServerDisconnect serverDisconnectCallback, void* state);
export boolean TCPClient_Send(TCPClient* client, uint8* buffer, uint16 length);
export void TCPClient_Disconnect(TCPClient* client);
#endif