Thank you.  Another question, how can I tell if the program opening
sockets is crashing enough times to cause problems for other processes?
My hypothesis is that this program opens 3 sockets and crashes, sockets
linger for a while.  Do this n times, the Pi starts to have problems.
If the Pi is resource starved, that will affect the NFS server running
on it.

On 2017-11-14 12:48, John Meissen wrote:
Sockets are just file descriptors. All file descriptors should be closed automatically as part of the process termination cleanup that the system does.

While it's good practice to handle these sorts of things they will happen
automatically if you don't.

In C there is an atexit function that takes no arguments.  Because of
this, you can't pass in the
file descriptors for your sockets. Uge! Short of making these integers
global, how can I close
these sockets on premature program termination?

int client=0,server=0;

void exiting()
{
     close(client);
     close(server);
}

int main(void)
{
     atexit(exiting);

     struct sockaddr...
}

Note that there are a bunch of includes for TCP sockets and a lot more
code.
_______________________________________________
PLUG mailing list
PLUG@pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug


_______________________________________________
PLUG mailing list
PLUG@pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug
_______________________________________________
PLUG mailing list
PLUG@pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to