gpt4 book ai didi

c# - 2 个 Socket.EndReceive 函数之间的区别

转载 作者:太空宇宙 更新时间:2023-11-03 15:13:40 25 4
gpt4 key购买 nike

我无法从文档中看出这两者之间的区别:

Socket.EndReceive Method (IAsyncResult, SocketError)

Socket.EndReceive Method (IAsyncResult)

第一个输出错误而第二个抛出错误吗?

编辑:

更具体地说:如果抛出错误,输出参数将是伪造的。这表明 SocketError 版本不会抛出错误。然而它说它抛出相同的错误 classes。这是否意味着它会抛出所有相同的错误?也许有错误发生但没有被抛出。也许您需要使用此函数来获取所有错误。我是否需要两组错误处理——一组用于抛出,一组用于输出参数?一种功能优于另一种功能吗?

最佳答案

根据文档,它们的行为相同。唯一的区别是错误处理时的额外参数。

基于注释

If you receive a SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.

看来你可以使用SocketError enumSocket.EndReceive 方法(IAsyncResult,SocketError) 上作为引用传递的对象,无需检查 Windows Sockets version 2 API 错误代码文档即可获取有关错误信息的信息/p>

关于c# - 2 个 Socket.EndReceive 函数之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39968841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com