Пример #1
0
 /// <summary>
 /// 监听客户端连接
 /// </summary>
 private void ListenClientConnect()
 {
     while (true)
     {
         Socket client = m_TcpSocket.Accept();
         m_serverReceiveClient = new ServerReceiveClient(client);
         Clients.Add(client);
         Debug.Log("<color=#00ff00>有客户端连接!</color>");
         IPEndPoint point = client.RemoteEndPoint as IPEndPoint;
         Debug.Log("客户端IP:" + point.Address + ",端口:" + point.Port);
     }
 }
Пример #2
0
    public void Dispose()
    {
        if (m_TcpSocket == null || m_serverReceiveClient == null)
        {
            return;
        }
        //m_TcpSocket.Shutdown(SocketShutdown.Both);

        m_serverReceiveClient.Dispose();
        m_TcpSocket.Close();

        m_serverReceiveClient = null;
        m_TcpSocket           = null;
        Debug.Log("关闭服务器socket");
    }