The protocol for a socket is chosen when the socket is created. Figure 1 shows an example program for sending datagram to a well-known server called the UDP echo server residing on machine s. The returned structure includes the host's network address, which is copied into the structure specifying the destination of the message. The port number can be thought of as the number of a mailbox, into which the protocol places one's messages. These fall in the range from 1 to 1023.
Higher numbers are available to general users.
Only servers need to ask for a particular number.