summaryrefslogtreecommitdiff
path: root/Runtime/Network/ServerSocket.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-14 22:50:43 +0800
committerchai <chaifix@163.com>2019-08-14 22:50:43 +0800
commit15740faf9fe9fe4be08965098bbf2947e096aeeb (patch)
treea730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Network/ServerSocket.h
+Unity Runtime codeHEADmaster
Diffstat (limited to 'Runtime/Network/ServerSocket.h')
-rw-r--r--Runtime/Network/ServerSocket.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/Runtime/Network/ServerSocket.h b/Runtime/Network/ServerSocket.h
new file mode 100644
index 0000000..89fd375
--- /dev/null
+++ b/Runtime/Network/ServerSocket.h
@@ -0,0 +1,31 @@
+#ifndef SERVERSOCKET_H
+#define SERVERSOCKET_H
+
+#if ENABLE_SOCKETS
+#include "Sockets.h"
+#include "SocketConsts.h"
+
+class ServerSocket : protected Socket
+{
+public:
+ ServerSocket(int domain = AF_INET, int type = SOCK_STREAM, int protocol = IPPROTO_TCP);
+
+ bool StartListening(unsigned short port, bool block);
+ bool StartListening(const char* ip, unsigned short port, bool block);
+#if !UNITY_WINRT
+ bool StartListening(const sockaddr* addr, socklen_t addr_len, bool block);
+#endif
+
+ int GetPort();
+ bool IsListening() const { return m_IsListening; }
+
+ TSocketHandle Accept();
+#if !UNITY_WINRT
+ TSocketHandle Accept(sockaddr* addr, socklen_t* addr_len);
+#endif
+private:
+ bool m_IsListening;
+};
+
+#endif // ENABLE_SOCKETS
+#endif // SERVERSOCKET_H