【问题标题】:Is Socket.BeginReceive(IList<ArraySegment<byte>> buffers.. Not Asynchronous?是 Socket.BeginReceive(IList<ArraySegment<byte>> 缓冲区.. 不是异步的吗?
【发布时间】:2009-07-07 13:20:09
【问题描述】:

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

IList<ArraySegment<byte>>

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

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

MSDN Documentation

在测试的时候我发现调用的时候

BeginReceive(IList..

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

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

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

谢谢!

【问题讨论】:

    标签: sockets asynchronous ilist buffering beginreceive


    【解决方案1】:

    所以!我发现了问题。

    因为我有一个

    Console.WriteLine
    

    出现在我的自定义中

    IList<ArraySegment<byte>>
    

    那么该方法在编译时没有异步执行:)

    【讨论】:

    • 克里斯的几率是多少:)
    猜你喜欢
    • 2013-03-12
    • 1970-01-01
    • 2014-09-13
    • 2014-03-26
    • 1970-01-01
    • 2017-04-20
    • 1970-01-01
    • 2012-03-11
    • 1970-01-01
    相关资源
    最近更新 更多