Talk C Chestnut Bar (145th: C Language Example--socket overview)

Source: Internet
Author: User

Ladies and gentlemen, crossing, the last time we were talking about file manipulation based on file pointers, the example we're talking about is the socket overview. Gossip Hugh, words return to the positive. Let's talk C chestnuts together!

Crossing, we are mainly introducing sockets today. "The previous chapter back in the introduction of file operations, how suddenly this is called the socket of things?" "Here's crossing asking, crossing, we're introducing the socket because it's kind of like a file descriptor in a file operation. Saying something like a bit less accurate, in fact the socket is essentially a file descriptor. We can use system calls such as read,write to operate the socket. Of course, the system also provides a dedicated system call to the socket, which we'll cover in the later Zhanghui.

There's another reason we're introducing the socket here, and we remember that when we introduced the file operation, we just introduced the process and the process communication-related knowledge. In fact, the socket is also a process of communication between the way. So, as you can understand, we are introducing another way of communicating between processes.

Having said so much, let's look at the veil of the socket to see its true colors . A socket is also called a socket, which is a way of communicating between processes. It is developed from UNIX and has been widely used in other systems such as Linux and Windows. Two processes on the local computer can communicate through the socket, which is the same way that other processes communicate with each other. In addition, it is the main function of the network in different computers on the process of communication between, in short, it is the network process between the communication mode. This feature makes communication between other processes a very different way.

A socket is a bridge that connects different computers in the network, which can communicate using sockets. Instead of focusing on the details of the communication, we only need to follow the rules using the socket. Let's give a common example to illustrate. We often use a browser to access a Web page, where a browser on the local computer establishes a connection to the server where the page resides. This connection is established through the socket, when we browse the Web page, the Web server will transfer data to the browser through the connection, so that we can see the contents of the page above.

Crossing, here's an example of the socket we're talking about here. I want to know what the following example, and listen to tell.

Talk C Chestnut Bar (145th: C Language Example--socket overview)

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.