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
> [email protected]
> http://lists.pdxlinux.org/mailman/listinfo/plug


_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to