简体   繁体   English

C#IRC客户端未发送数据(似乎)

[英]C# IRC client not sending data (it seems)

A friend and I are working on an IRC client in C#, just for practice. 我和一个朋友正在用C#开发IRC客户端,只是为了练习。

We've implemented it so that it listens for data all the time on a separate thread, even though I don't believe that this should interfere in any way. 我们已经实现了它,以便它始终在单独的线程上侦听数据,即使我认为这不会以任何方式干扰。

We have a IRCClient class that uses the following Send method, which, apparently doesn't work. 我们有一个IRCClient类,它使用以下Send方法,该方法显然不起作用。

public void Send(string command)
{
    NetworkStream stream = this.client.GetStream();
    StreamWriter writer = new StreamWriter(stream);

    writer.Write(command + "\r\n");
    writer.Flush();
}

The "client" attribute is a TcpClient that is properly connected to the IRC server. “客户端”属性是正确连接到IRC服务器的TcpClient And yes, we can receive data. 是的,我们可以接收数据。

You can use Wireshark ( http://www.wireshark.org/ ) in order to check the raw data you send and receive. 您可以使用Wireshark( http://www.wireshark.org/ )来检查您发送和接收的原始数据。 It has support for IRC protocol and it will help you a lot with debugging your client. 它支持IRC协议,它将在调试客户端方面为您提供很多帮助。

I figured out that the IRC client (in order to send commands) must exclude the preceding slash "/". 我发现IRC客户端(为了发送命令)必须排除前面的斜杠“ /”。 So instead of "/say hello", you just have to send "SAY hello". 因此,您不必发送“ / say hello”,而只需发送“ SAY hello”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM