Is there a way to close a Unix socket for reading or writing?

Is there a way to close only the “one end” of a TCP socket to clearly indicate that one side of the connection is made by recording the connection? (Just like you do with a pipe in every Unix pipe tutorial ever.) Or do I need to use some kind of in-band solution, like a sentinel value or something like that?

+3
source share
1 answer

You can disable the socket for reading or writing using the second parameter for the method:

shutdown(sock, SHUT_RD)
shutdown(sock, SHUT_WR)

shutdown() , , ( , ). , .

+5

Source: https://habr.com/ru/post/1740060/


All Articles