3

When using TCP & UDP sockets, there are many scenarios which cause connection interruption (slow connection, network reset, etc). Is there any possible situation which an unix domain socket automatically disconnects or interrupts because of an external reason? Should developers consider possible interruption in their codes?

5
  • 2
    Without even considering the full question, a developer should always consider and expect the unexpected, including interruptions. So the simple answer is yes, expect to handle such a case, even if it's not supposed to be possible. Errors and bugs happen. And finding them is much harder when you do not write your code from the start to be prepared for them to happen.
    – C. M.
    Apr 27, 2021 at 12:50
  • 1
    Murphy's Law applies to programming. Anything that can fail, will fail, usually at the least convenient time.
    – waltinator
    Apr 27, 2021 at 14:42
  • Thanks for your suggestion guys, but my question is more than just "consideration".
    – AmirHmZ
    Apr 27, 2021 at 17:10
  • It's always possible that server will terminate unexpectedly, no matter what type of socket or IPC mechanism is used. May 2, 2021 at 13:15
  • 1
    @ArkadiuszDrabczyk and where that possibility comes from ?
    – AmirHmZ
    May 3, 2021 at 14:06

1 Answer 1

1
+50

It's always possible that server will terminate unexpectedly, no matter what type of socket or IPC mechanism is used. It can happen for many different reasons, for example:

  • it may crash because of software bug, for because due to segmentation fault or failed assertion

  • it may eat too much memory and can get killed by Linux OOM killer (it's very easily reproducible in virtual machine)

  • it may be killed erroneously by another user. Linux is multi-user system and it's possible that someone could accidentally killed your process, say they wanted to type kill 1112 but typed kill 1111 instead

Should developers consider possible interruption in their codes?

Yes, they always should. Read manpage of the function you're going to use and read all possible values of errnos that the function can set and always prepare for the worst.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .