NEXT UP previous
Next: Questions

Socket Server Changes

All the other changes to the original example socket server are directly related to enabling the daemon to deal with errors returned from system and library calls. This is done by restarting the daemon's main loop where appropriate, rather than just terminating the daemon when any error occurs. The implementation of this idea has been achieved by adding an extra parameter to the fatal() function to specify what its next_action should be, after printing out its error message. The options are: NA_EXIT in which case the the calling process terminates, or NA_RESTART, where use is made of the setjmp() and longjmp() library routines to cause a non-local jump back to the start of the main server loop. In fact, this restart facility is only used for errors detected within the main loop of the parent process. If any errors are detected within a client serving child process, then this process is allowed to terminate as before.


NEXT UP previous
Next: Questions