HPlogo HP 9000 Networking: BSD Sockets Interface Programmer's Guide > Chapter 7 Using UNIX Domain Datagram Sockets

Closing a Socket

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Glossary

 » Index

In most applications, you do not have to close the sockets. When you exit your program and your process terminates, the sockets are closed for you.

If you need to close a socket while your program is still running, use the close system call.

You may have more than one process with the same socket descriptor if the process with the socket descriptor executes a fork. close decrements the file descriptor count and the calling process can no longer use that file descriptor. When the last close is executed on a socket, any unsent messages are sent and the socket is closed. Any unreceived data are lost.

© 1997 Hewlett-Packard Development Company, L.P.