Socket.BeginReceive(IList> 缓冲区..不是异步的吗?

发布于 2024-07-26 11:42:11 字数 569 浏览 3 评论 0 原文

我一直在寻找实现一个自定义类:

IList<ArraySegment<byte>>

这将被传递到套接字,并用作从该套接字接收数据的缓冲区。

Socket.BeginReceive(
    IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object
    )

MSDN 文档

在测试时我发现在调用

BeginReceive(IList. 。

它会阻塞?!当用 BeginReceive(byte[]... 替换它时,它是异步操作的。

还有其他人遇到过这个吗?

如果需要,我会发布我的测试代码,但想听听在我丑化这个问题之前,来自任何人的意见:)

谢谢!

I have been looking to implement a custom class of :

IList<ArraySegment<byte>>

this will be passed to a socket, and used as the buffer to receive data from that Socket.

Socket.BeginReceive(
    IList<ArraySegment<Byte>>, SocketFlags, AsyncCallback, Object
    )

MSDN Documentation

While testing I have found that when calling

BeginReceive(IList..

It blocks?! When replacing this with the BeginReceive(byte[]... is acts asynchronously.

Has anyone else come accross this?

I will post my testing code up if required but would like to hear from anyone out there before I uglify this question :)

Thanks!

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

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

发布评论

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

评论(1

素年丶 2024-08-02 11:42:11

所以! 我发现了这个问题。

有一个

Console.WriteLine

由于我的自定义中

IList<ArraySegment<byte>>

礼物,因此该方法在编译时没有异步执行:)

So! I found out the issue.

As I had a

Console.WriteLine

present in my custom

IList<ArraySegment<byte>>

then the method was not acting asynchronously on compile :)

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