0

我创建了一个 TCP 侦听器,我从客户端接收来自 pc 的 IP 和 HWID。现在我希望侦听器通过 hiwd 接收并保存在文本文件中来阻止从客户端接收到的 ip。那可能吗?这是监听器代码。

tcpListener = new TcpListener(IPAddress.Any, 8000);
listenThread = new Thread(new ThreadStart(ListenForClients));
listenThread.Start();

private static void HandleClientComm(object client)
{
    TcpClient tcpClient = (TcpClient)client;
    //   NetworkStream clientStream = tcpClient.GetStream();
    clientStream = tcpClient.GetStream();

    byte[] message = new byte[65536];
    int bytesRead;

    bytesRead = 0;

    // Blocks until a client sends a message      

    bytesRead = clientStream.Read(message, 0, message.Length);
    {
        // Message has successfully been received
        ASCIIEncoding encoder = new ASCIIEncoding();

        // Output message
        string hwidban = File.ReadAllText("hwid.txt");

        if (encoder.GetString(message, 0, bytesRead) == hwidban)
        {
        //BLOCK IP CODE

        }
        else
        {

        //Console.WriteLine("To: " + tcpClient.Client.LocalEndPoint);
        textFromClient = ("IP at:  " + tcpClient.Client.RemoteEndPoint + " HardwareID:" + encoder.GetString(message, 0, bytesRead));

            //Console.WriteLine(encoder.GetString(message, 0, bytesRead));

        } while (clientStream.DataAvailable) ;

        // Release connections
        //  clientStream.Close();

        //tcpClient.Close();
    }
}
4

0 回答 0