user0x0
user0x0

Reputation: 263

What can be done if socket creation fails in a service?

I am writing a linux service which will communicate using sockets to client.

This service will be started at the boottime and will run forever till the device is alive. In this case, at the server, if socket creation fails, how can I handle this error?

Upvotes: 0

Views: 780

Answers (1)

cnicutar
cnicutar

Reputation: 182619

There's not much you can do:

  • If the listening socket can't be created, print an error message and exit, hoping someone sees it. There's not much a server can do if it can't listen on some sort of socket

  • If a new socket can't be created (using accept) log a warning message and hope someone sees it, but don't exit. The error condition (too many open descriptors, not enough memory etc) might be temporary

Upvotes: 2

Related Questions