BeginSend
函数不会抛出异常。有趣的是OnSend
回调函数调用和结果。
Iscompleted
返回true。
如果我使用错误代码调用另一个重载函数,它总是返回success
tcpAsyCl.BeginSend(
write_data,
0,
write_data.Length,
SocketFlags.None,
out error,
new AsyncCallback(OnSend),
null);
if (error != SocketError.Success)
throw new Exception("Not connected"); //never goes her
有谁知道这种行为?
答案 0 :(得分:1)
因为这是一个异步电话!您无法在下面的行中验证结果...我确定您有一个方法可以连接以获得正确的错误。
异步调用是在新线程中创建的,您需要等待答案。不在主线程中,或者是同步调用。
这是您可以使用的list of all methods
我强烈建议您深入了解本文档