Linux socket using multiple threads to send
问题 I have a single non-blocking socket sending udp packets to multiple targets and receiving responses from all of them on the same socket. I'm reading in a dedicated thread but writes (sendto) can come from several different threads. Is this a safe without any additional synchronization? Do I need to write while holding a mutex? Or, do writes need to come from the same thread and I need a queue? 回答1: The kernel will synchronize access to underlying file descriptor for you, so you don't need a