-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServerLibrary.cs
83 lines (55 loc) · 2.97 KB
/
ServerLibrary.cs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace Networking {
internal static unsafe class ServerLibrary {
[DllImport ("Network")]
public static extern IntPtr Server_CreateServer ();
[DllImport ("Network")]
public static extern Int32 Server_sendBytes (IntPtr serverPtr, EndPoint ep, IntPtr buffer, UInt32 len);
[DllImport ("Network")]
public static extern Int32 Server_recvBytes (IntPtr serverPtr, EndPoint * ep, IntPtr buffer, UInt32 len);
[DllImport ("Network")]
public static extern Int32 Server_PollSocket (IntPtr serverPtr);
[DllImport ("Network")]
public static extern Int32 Server_SelectSocket (IntPtr serverPtr);
[DllImport ("Network")]
public static extern Int32 Server_initServer (IntPtr serverPtr, ushort port);
[DllImport ("Network")]
public static extern IntPtr Client_CreateClient ();
[DllImport ("Network")]
public static extern Int32 Client_sendBytes (IntPtr clientPtr, IntPtr buffer, UInt32 len);
[DllImport ("Network")]
public static extern Int32 Client_recvBytes (IntPtr clientPtr, IntPtr buffer, UInt32 len);
[DllImport ("Network")]
public static extern Int32 Client_PollSocket (IntPtr clientPtr);
[DllImport("Network")]
public static extern Int32 Client_SelectSocket(IntPtr clientPtr);
[DllImport ("Network")]
public static extern Int32 Client_initClient (IntPtr clientPtr, EndPoint ep);
[DllImport("Network")]
public static extern IntPtr TCPServer_CreateServer();
[DllImport("Network")]
public static extern Int32 TCPServer_initServer(IntPtr serverPtr, ushort port, ushort timeout);
[DllImport("Network")]
public static extern Int32 TCPServer_acceptConnection(IntPtr serverPtr, EndPoint * ep);
[DllImport("Network")]
public static extern Int32 TCPServer_sendBytes(IntPtr serverPtr, Int32 clientSocket, IntPtr data, UInt32 len);
[DllImport("Network")]
public static extern Int32 TCPServer_recvBytes(IntPtr serverPtr, Int32 clientSocket, IntPtr data, UInt32 len);
[DllImport("Network")]
public static extern Int32 TCPServer_closeClientSocket(Int32 clientSocket);
[DllImport("Network")]
public static extern Int32 TCPServer_closeListenSocket(Int32 sockfd);
[DllImport("Network")]
public static extern IntPtr TCPClient_CreateClient();
[DllImport("Network")]
public static extern Int32 TCPClient_initClient(IntPtr serverPtr, EndPoint ep);
[DllImport("Network")]
public static extern Int32 TCPClient_sendBytes(IntPtr serverPtr, IntPtr data, UInt32 len);
[DllImport("Network")]
public static extern Int32 TCPClient_recvBytes(IntPtr serverPtr, IntPtr data, UInt32 len);
[DllImport("Network")]
public static extern Int32 TCPClient_closeConnection(Int32 sockfd);
}
}