1
2
3
4
5
6 #ifndef CMAJOR_RT_SOCKET_INCLUDED
7 #define CMAJOR_RT_SOCKET_INCLUDED
8 #include <cmajor/rt/RtApi.hpp>
9 #include <stdint.h>
10
11 enum class ShutdownMode : int32_t
12 {
13 receive= 0, send= 1, both= 2
14 };
15
16 enum class ConnectOptions : int32_t
17 {
18 none= 0, useTls= 1 << 0
19 };
20
21 inline ConnectOptions operator&(ConnectOptions left, ConnectOptions right)
22 {
23 return ConnectOptions(int32_t(left) & int32_t(right));
24 }
25
26 inline ConnectOptions operator|(ConnectOptions left, ConnectOptions right)
27 {
28 return ConnectOptions(int32_t(left) | int32_t(right));
29 }
30
31 extern "C" void* RtCreateSocket(int32_t& errorStringHandle);
32 extern "C" bool RtBindSocket(void* socketHandle, int32_t port, int32_t& errorStringHandle);
33 extern "C" bool RtListenSocket(void* socketHandle, int32_t backLog, int32_t& errorStringHandle);
34 extern "C" void* RtAcceptSocket(void* socketHandle, int32_t& errorStringHandle);
35 extern "C" bool RtCloseSocket(void* socketHandle, int32_t& errorStringHandle);
36 extern "C" bool RtShutdownSocket(void* socketHandle, ShutdownMode mode, int32_t& errorStringHandle);
37 extern "C" void* RtConnectSocket(const char* node, const char* service, ConnectOptions options, int32_t& errorStringHandle);
38 extern "C" int32_t RtSendSocket(void* socketHandle, uint8_t * buf, int32_t len, int32_t flags, int32_t& errorStringHandle);
39 extern "C" int32_t RtReceiveSocket(void* socketHandle, uint8_t * buf, int32_t len, int32_t flags, int32_t& errorStringHandle);
40 extern "C" void RtDestroySocket(void* socketHandle);
41
42 namespace cmajor { namespace rt {
43
44 void InitSocket();
45 void DoneSocket();
46
47 } }
48
49 #endif // CMAJOR_RT_SOCKET_INCLUDED