【发布时间】:2020-06-18 22:09:19
【问题描述】:
好的,所以我一直在制作一个异步 IRC,它工作正常,除了一个问题。客户端可以写,服务器可以读。除了服务器不能写,客户端不能读。有什么帮助吗?
https://github.com/theprogrammer4568/IRC
async public static Task Receive()
{
while(true)
{
Byte[] bytes = new Byte[256];
int data = await Server.stream.ReadAsync(bytes, 0, bytes.Length);
string message = System.Text.Encoding.ASCII.GetString(bytes, 0, data);
Console.WriteLine(message);
}
}
async public static Task Send()
{
while(true)
{
Byte[] bytes = new Byte[256];
string message = Console.ReadLine();
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
await Server.stream.WriteAsync(data, 0, data.Length);
}
}
async static Task Async()
{
await Task.Run(Read.Receive);
await Task.Run(Write.Send);
}
【问题讨论】:
-
Bytes变量的用途是什么? -
很抱歉给您带来不便,我是 StackOverflow 的新手。但我已经更新了我的帖子。
标签: c# asynchronous irc