我创建了一个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();
}
}