Socket sockets for computer networks

Source: Internet
Author: User

When an application process initiates a system call , control is passed from the application process to the system call interface.

This interface then passes control to the computer's operating system. The operating system forwards this call to an internal procedure and performs the requested operation.

Once the internal process is executed, control is returned to the application process via the system call interface.

The system invocation Interface is actually an interface for the application process Control and the control of the operating system to be transformed, namely the application programming Interface API(application programming Interface).

The most famous API for the TCP/IP protocol is the socket interface (SOCKETINTERFACE) defined by the Berkeleyunix operating system. Microsoft has adopted the socket interface API in its operating system, creating a slightly different API, called the Windows socket.

Note that the process above the socket is controlled by the application, while the Transport Layer protocol software under the socket is controlled by the computer's operating system. Therefore, as long as the application communicates using the TCP/IP protocol, it must interact with the operating system through the socket and request its services.


A system call is made when the application process needs to communicate with the network, requesting the operating system to create a "socket" for it to allocate the system resources required for network communication to the application process.

The operating system represents the sum of these resources with a number called a socket descriptor and returns this number to the application process. This number must be used for network operations performed by the application process.

After the communication is complete, the application process notifies the operating system through a system call to close the socket that all resources related to the "number" are recycled.

Describes the relationship between the socket descriptor created by the operating system and the socket data structure:


Because multiple sockets may appear in one machine at the same time, a table that holds the socket descriptor is required, and each socket descriptor has a pointer to the address where the socket is stored.

When the socket is created, its port number and IP address are empty, so the application process calls bind (BIND) to indicate the local address of the socket. When BIND is invoked on the server side, the well-known port number and local IP address are filled into the created socket. This is called binding the local address to the socket .

After the server calls bind, it must also call listen (listen) to set the socket to passive so that it can accept customer service requests at any time. The UDP server does not use listen system calls because it only provides a no-connect service.

The server immediately calls accept to extract the connection request from the remote client process. One of the variables that the system calls accept is to indicate the connection from which socket originated.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Socket sockets for computer networks

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.