How to signal select() to return immediately?

后端 未结 3 2065
温柔的废话
温柔的废话 2020-11-28 12:48

I have a worker thread that is listening to a TCP socket for incoming traffic, and buffering the received data for the main thread to access (let\'s call this socket A

3条回答
  •  余生分开走
    2020-11-28 13:20

    Using a pipe rather than socket is a bit cleaner, as there is no possibility for another process to get hold of it and mess things up.

    Using a UDP socket definitely creates the potential for stray packets to come in and interfere.

    An anonymous pipe will never be available to any other process (unless you give it to it).

    You could also use signals, but in a multithreaded program you'll want to make sure that all threads except for the one you want have that signal masked.

提交回复
热议问题