.NET Socket Send()/ Receive()线程安全吗?

时间:2022-10-17 07:36:06

Since a socket is full duplexed, meaning you can send and recieve simultaneously. So, is the .NET Socket Send()/Receive() thread-safe? I need to Send() and Receive() in 2 threads.

由于套接字是全双工的,这意味着您可以同时发送和接收。那么,.NET Socket Send()/ Receive()线程安全吗?我需要2个线程中的Send()和Receive()。

1 个解决方案

#1


8  

Quote from the MSDN docs about the Socket class (under Thread Safety, towards the end of the page):

引用来自MSDN文档的Socket类(在Thread Safety下,到页面末尾):

Instances of this class are thread safe.

此类的实例是线程安全的。

So I would suppose the answer is "yes".

所以我认为答案是肯定的。

#1


8  

Quote from the MSDN docs about the Socket class (under Thread Safety, towards the end of the page):

引用来自MSDN文档的Socket类(在Thread Safety下,到页面末尾):

Instances of this class are thread safe.

此类的实例是线程安全的。

So I would suppose the answer is "yes".

所以我认为答案是肯定的。