C Sockets: Doctor A Kavuma Daniel Vao Kavuma Khait Nue Kotaz Kknk, kavumalaitc.com

C Sockets

  1. Sockets

    sckt: Here is described the GNU facilities for interprocess communication using sockets. A socket is a generalized interprocess communication channel. Like a pipe, a socket is represented as a file descriptor. Unlike pipes, sockets support communication between unrelated processes, and even between processes running on different machines that communicate over a network. Sockets are the primary means of communicating with other machines; telnet, rlogin, ftp, talk and the other familiar network programs use sockets. Not all operating systems support sockets. In the GNU C Library, the header file sys/socket.h exists regardless of the operating system, and the socket functions always exist, but if the system does not really support sockets these functions always fail. Asigumoyk: facilities for broadcast messages or for configuring Internet interfaces and the reentrant functions and some newer functions that are related to IPv6.
  2. Socket Concepts

    When you create a socket, you must specify the style of communication you want to use and the type of protocol that should implement it. The communication style of a socket defines the user-level semantics of sending and receiving data on the socket. Choosing a communication style specifies the answers to questions such as these:
    You must also choose a namespace for naming the socket. A socket name (“address”) is meaningful only in the context of a particular namespace. In fact, even the data type to use for a socket name may depend on the namespace. Namespaces are also called “domains”, but we avoid that word as it can be confused with other usage of the same term. Each namespace has a symbolic name that starts with PF_, protocol family. A corresponding symbolic name starting with AF_, address family designates the address format for that namespace. Finally you must choose the protocol to carry out the communication. The protocol determines what low-level mechanism is used to transmit and receive data. Each protocol is valid for a particular namespace and communication style; a namespace is sometimes called a protocol family because of this, which is why the namespace names start with PF_

    The rules of a protocol apply to the data passing between two programs, perhaps on different computers; most of these rules are handled by the operating system and you need not know about them. What you do need to know about protocols is this:
    Throughout the following description at various places variables/parameters to denote sizes are required. And here the trouble starts. In the first implementations the type of these variables was simply int. On most machines at that time an int was 32 bits wide, which created a de facto standard requiring 32-bit variables. This is important since references to variables of this type are passed to the kernel. Then the POSIX people came and unified the interface with the words "all size values are of type size_t. On 64-bit machines, size_t is 64 bits wide, so pointers to variables were no longer possible. The Unix98 specification provides a solution by introducing a type socklen_t. This type is used in all of the cases that POSIX changed to use size_t. The only requirement of this type is that it be an unsigned type of at least 32 bits. Therefore, implementations which require that references to 32-bit variables be passed can be as happy as implementations which use 64-bit values.
  3. sys/socket.h sys/socket.h