TcpListener
을 사용하여 수신 메시지를 읽으려고합니다. 나는 청취자를 설치하고 메시지를 받는다. 그러나 그 메시지는 매우 이상합니다. 나는이납니다 :C# TcpListener가 메시지에 이상한 문자를 수신했습니다.
▬♥♥¡☺?♥♥YÄÂb #ù÷"MDòs←ç→.ge ûjò8┼#i(♥→å:À#À'<À%À)[email protected]À À‼/À♦À♫32À+À/oÀ-À1z¢À↕▬‼ÿ☺:▬¶↨↑↓▬¶♠♥♠☺♣♥♣☺♦♥♦☺♦☻☻♥☻☺☻☻
메시지는 HTTPS를 통해 다른 응용 프로그램 (나는이 응용 프로그램의 소스 코드가없는)로부터 전송합니다 (HTTPS는 문제가 그것을 할 수 있다는 점이다?). 어쨌든 내가 설정 한 청취자는 다음과 같습니다.
static void Main(string[] args)
{
TcpListener listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 11000);
Console.WriteLine("Listening...");
listener.Start();
TcpClient client = listener.AcceptTcpClient();
Console.WriteLine("Connection accepted.");
Thread t = CreateThread(client, false);
t.Start();
}
private static Thread CreateThread(TcpClient client)
{
Thread t = new Thread(delegate()
{
byte[] data = new byte[300];
client.Client.Receive(data);
Console.WriteLine("Received data: ");
string value = Encoding.Default.GetString(data);
Console.WriteLine(value);
});
return t;
}
메시지는 유효한 xml 트리 여야합니다. C# 및 .NET Framework 4.5.2를 사용하고 있습니다. 정확히 내가 뭘 잘못하고 있니?
응용 프로그램이 HTTPS 요청을 보내는 경우 왜 TcpListener를 사용하고 있습니까? – CodeCaster
https가 암호화되어 있습니다. ** 사용자가 직접 구현하지 않기를 바랍니다 **. –
@CodeCaster Tbh 저는 HTTPS에 익숙하지 않습니다. TcpListener 대신 무엇을 권하고 싶습니까? – Therk