简体   繁体   English

Unix 多播套接字线程安全吗?

[英]Are Unix multicast sockets thread safe?

Unix 多播套接字线程安全吗?

Depends on what you mean by thread-safe.取决于你所说的线程安全是什么意思。 It appears that making to calls to send() at the same time from separate threads will not crash your program, and all the data will be send across the network.似乎从不同的线程同时调用 send() 不会使您的程序崩溃,并且所有数据都将通过网络发送。

The problem is that if your message stretches across more than one packet.问题是,如果您的消息跨越多个数据包。 The packets may interleave and it will be up to the remote machine to sort out the two interleaved messages.数据包可能交错,这将由远程机器来整理两个交错的消息。

See: Be careful with the sendmsg() family of functions which I got from Are parallel calls to send/recv on the same socket valid?请参阅: 小心我从中获得的 sendmsg() 系列函数在同一个套接字上对 send/recv 的并行调用是否有效? . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM