我正在用 c# 编写一个 IRC 客户端,但我总是收到“No ident response”消息并且它只是断开连接。
代码
TcpClient client = new TcpClient(args[0], port);
sock.Connect(serverEndPoint);
NetworkStream stream = client.GetStream();
NetworkStream streamw = client.GetStream();
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
System.IO.StreamWriter writer = new System.IO.StreamWriter(streamw);
writer.WriteLine("loaloaloa");
IPEndPoint rep = (IPEndPoint)sock.LocalEndPoint;
while (true)
{
string bytes = reader.ReadLine();
Console.WriteLine("Received: {0}", bytes);
if (String.IsNullOrEmpty(bytes))
break;
}
这是消息
:kornbluth.freenode.net NOTICE * :*** Looking up your hostname...
:kornbluth.freenode.net NOTICE * :*** Checking Ident
:kornbluth.freenode.net NOTICE * :*** Found your hostname
:kornbluth.freenode.net NOTICE * :*** No Ident response
ERROR :Closing Link: 127.0.0.1 (Connection timed out)
我发现我必须在端口 113 上侦听才能获取消息,然后以相同的消息和更多信息进行响应。
所以我的问题是我如何开始监听端口 113,我将如何接受消息并响应?