TCP/IP Programming Learning 01

Source: Internet
Author: User

Network programming is the writing of multiple computers networked interactive data. The operating system will provide a part called socket (socket), socket is the network data transmission device software, so that network programming can also become socket programming.

In this borrowing book call example, the use of the socket to do a simple description:

1) First, a phone call, a new phone is equivalent to creating a telephone socket.

int socket (int domain, int type, int protocol);

2) Assign a number to the phone, bind the IP address and port number.

int bind (int sockfd, struct sockaddr* myaddr, socklen_t Addrlen);

After calling the Bind method to assign an address (IP, port number) to the socket, it completes the creation of the socket, and the next thing to do is to link the socket as needed.

3) connect the phone (socket) so that it can communicate with the phone and set the socket status to receive status.

int listen (int sockfd, int backlog);

4) Set the phone status, when there is a telephone access, the socket calls the Accept method, when there is a link to the request (there is a call, that is, a different program to link), to accept (socket communication).

int accept (int sockfd, struct sockaddr* addr, socklen_t* Addrlen);


TCP/IP Programming Learning 01

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.