VB IRC 客户端 - writeStream 仅在 IRC 中显示单个单词

发布于 2024-10-02 12:35:25 字数 1033 浏览 7 评论 0原文

大家早上好,

我一直在用 Visual Basic 编写一个非常简单的 IRC 客户端。当我写入网络流时,我遇到了一个小问题。在其他客户端上,我的消息在第一个空格字符后被切断。我确信这很简单,因为消息正在发送,接收很好,并且在我阅读消息的任何地方调试问题(即,如果我 debug.print 写入流的消息,它仍然包含所有单词和空格.)这是我的代码。

提前致谢

'Send data to IRC Server
Sub Send(ByVal message)
    Try

        'Reformat message to IRC command
             message = message & vbCrLf
             Debug.Print(message)
        'Convert message string into bytes
         Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(message)

        'Write data to stream
         ircStream.Write(sendBytes, 0, sendBytes.Length)

        'Run test to see if the string sent matches the user input
         Dim messageSent As String = Encoding.ASCII.GetString(sendBytes)
         Debug.Print(messageSent)

        'Display message on the screen( 0 = Sent Formatting )
         PrintToScreen(message, 0)

    Catch ex As Exception
        'Catch error and display error message in the debug console
         Debug.Print("Error Sending")

    End Try
End Sub

Morning All,

I have been writing an ever so simple IRC client in visual basic. I have a niggly issue whereby when I am writing to the network stream. On other clients my message cuts off after the first space character. I'm sure this is something simple as the messages are being sent, receiving is fine and debugging the issue it wherever I read the message (i.e. if I debug.print the message being written to the stream it still includes all the words and spaces.) Here is my code.

Thanks in advance

'Send data to IRC Server
Sub Send(ByVal message)
    Try

        'Reformat message to IRC command
             message = message & vbCrLf
             Debug.Print(message)
        'Convert message string into bytes
         Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(message)

        'Write data to stream
         ircStream.Write(sendBytes, 0, sendBytes.Length)

        'Run test to see if the string sent matches the user input
         Dim messageSent As String = Encoding.ASCII.GetString(sendBytes)
         Debug.Print(messageSent)

        'Display message on the screen( 0 = Sent Formatting )
         PrintToScreen(message, 0)

    Catch ex As Exception
        'Catch error and display error message in the debug console
         Debug.Print("Error Sending")

    End Try
End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阳光下的泡沫是彩色的 2024-10-09 12:35:25

您可能只需要在消息前面添加一个“:”,如下所示......

PRIVMSG #chan_name:您的消息带有空格

You probably just need to prepend a ':' to your message like so...

PRIVMSG #chan_name :your message with spaces

夏雨凉 2024-10-09 12:35:25

通过刷新,调用流的刷新函数...(如果我没记错的话)清除缓冲区中的数据,并同时写入。

ircStream.Flush()

By flushing, calling the flush function of the stream... Which (if I remember correctly) clears the data in the buffer, and writes it at the same time.

ircStream.Flush()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文