public void StartDebugTcpServer(int port) { var endpoint = new IPEndPoint(IPAddress.Any, port); // var server = new TcpServer.Server(endpoint, SocketType.Dgram, ProtocolType.Udp); var server = new Net.Server(endpoint); // server.GetSocket().SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); // server.GetSocket().SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000); server.OnClientConnected += (object sender, OnClientConnectedHandler e) => { server.SendCacheMessage(e.GetClient()); }; server.OnClientDisconnected += (object sender, OnClientDisconnectedHandler e) => { AppLog.d(Tag, "Client {0} Disconnected", e.GetClient().GetGuid()); }; server.OnMessageReceived += (object sender, OnMessageReceivedHandler e) => { // server.GetSocket().SendTo(System.Text.Encoding.UTF8.GetBytes(e.GetMessage()), endpoint); server.BroadcastMessage(System.Text.Encoding.UTF8.GetBytes(string.Format("{0}:\n\t{1}", e.GetClient().GetGuid(), e.GetMessage())), e.GetClient()); }; server.OnSendMessage += (object sender, OnSendMessageHandler e) => { //AppLog.d(Tag, "Sent message: '{0}' to client {1}", e.GetMessage(), e.GetClient().GetGuid()); }; m_debugServer = server; }