how to create a socket ?
why to bind a socket?
when we use a socket?

A socket is a data-structure used for interprocess communications, generally associated with network communications. You create them via access to kernel system calls that create sockets. These system calls may be C programming interfaces to the kernel, or they may be created via higher level languages such as PERL, PHP, PYTHON, etc.

When you create a socket, you only create the data structure. You must bind the process to the data structure in order to listen, read, and write between the socket and the process which is bound to the socket.

Sockets are generally used between processes over the network. I suggest you study Steven's book, "UNIX Network Programming," to gain an appreciation of sockets and network programming. Here is an link to a later (maybe better) edition of UNIX Network Programming by Rich Stevens (a true UNIX hero!)

<A HREF=""><IMG SRC="" border="0" alt="cover" hspace="3" vspace="3"></A>

<A HREF=""><IMG SRC="" border="0" alt="cover" hspace="3" vspace="3"></A>


Also, here are more discussions and pointers in a related thread: