"Linux Advanced Programming" (13th) Linux Socket Network Programming Fundamentals 2

Source: Internet
Author: User
BSD Socket Network Programming API creates socket object

int socket (int __domain, int __type, int __protocol) : Successfully returns the socket file descriptor, failure returns-1.

Parameter 1:socket the address cluster or protocol family used by the object

Commonly used are pf_local (native communication), Pf_inet (IPV4 protocol cluster), PF_INET6 (IPV6 protocol cluster)

The type of the parameter 2:socket. Common: connection-oriented data flow mode; Non-connected datagram mode

Parameter 3: Identifies which protocol to use, and 0 indicates default.

Bind the IP address to the port

int bind (int __fd, __const_sockaddr_arg __addr, socklen_t __len) : Successfully returned 0, failed return-1

Parameter 1: File descriptor for binding to the ground IP

Parameter 2: Pointer to SOCKADDR structure, identifying local address information

"Linux Advanced Programming" (13th) Linux Socket Network Programming Fundamentals 2

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.