且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Linux套接字使用多个线程发送

更新时间:2023-11-22 17:14:10

内核将为您同步对底层文件描述符的访问,因此您不需要单独的互斥体.如果您使用的是TCP,则这种方法会出现问题,但是由于我们在谈论UDP,因此这应该是安全的,尽管不一定是***的方法.

The kernel will synchronize access to underlying file descriptor for you, so you don't need a separate mutex. There would be a problem with this approach if you were using TCP, but since we are talking about UDP this should be safe, though not necessarily best way.