Reputation: 1215
Could I close the sending (TCP) socket whenever I want?
Are there any cases to avoid using close(socket_name)
?
Upvotes: 0
Views: 81
Reputation: 311023
could I close the sending (TCP) socket whenever I want?
Yes, subject to below.
Are there any cases to avoid using close(socket_name)?
Yes. You shouldn't close when you are concurrently blocked in an operation on that socket, e.g. recv(), send(), select()
, unless the surrounding code is written so as to handle EBADF
correctly.
Upvotes: 1