What the hell is a socket.

Source: Internet
Author: User

The socket is translated as a "communication node" in computer jargon. The computer network illustrates that communication between computers is often referred to as communication between applications. And the application between the use of sockets to communicate, it can be simple to think that the socket encapsulates the implementation of the TCP/IP protocol, we can use the high-level computer language in an abstraction layer to achieve computer communication, without regard to specific details.

The most common form of communication is the client-server form, we open the Internet browser, login QQ Chat, this is the form. Browser/QQ is the client, and the website is the Web server, QQ Chat server is the service side.

The service side listens to a port through the socket, and contracts the protocol, the client establishes the connection through the socket and the server, then communicates through the specific protocol and the service side.

in the case of a Web server, it starts, listens on port 80, and contracts with the HTTP protocol. When the browser accesses the Web server, establishes a connection, sends an HTTP request, the Web server processes the request, and returns the content. After the browser receives the return information, it renders in the browser and disconnects.

The connection mentioned above is actually a socket connection, because it is implemented using a socket. It is important to note that the above process is the simplest form, the server can not actively send data to the client, once the request is completed, the connection is disconnected.

at some point, the socket connection is established and will remain, such as a chat app. When QQ and chat server establish a connection, the client can send a message to the server, when there are new messages, the server can also proactively push messages to the client. The connection will not be broken unless the user exits QQ, which is the long socket connection. And we usually see between Web servers and browsers called short connections.


What the hell is a socket.

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.