Socket programming (1)

Source: Internet
Author: User

Socket Definition

Network Programming in Linux is implemented through the socket interface. The socket is a special I/O interface, which is also a file descriptor. Socket is a common communication mechanism between processes. It not only enables communication between processes on local machines, but also enables communication between processes on different machines through the network.

Each socket is represented by a semi-Related Description {protocol, local address, and port number; A complete socket is represented by a description {protocol, local address, local port, remote address, remote port. Socket also has a function call similar to opening a file. This function returns an integer socket descriptor, and subsequent connection establishment and data transmission operations are implemented through socket.

Socket Type

(1) stream socket

Stream socket (sock_stream ).

Stream sockets provide reliable and connection-oriented communication streams. They use the TCP protocol to ensure the correctness and sequence of data transmission.

(2) datagram socket (sock_dgram)

A datagram socket defines a connectionless service. Data is transmitted through independent packets, which is out of order and is not guaranteed to be reliable and error-free. It uses the datagram protocol (UDP)

(3) original socket

The original socket allows direct access by the underlying protocol, such as IP or ICMP. It is powerful but inconvenient to use and is mainly used for the development of some protocols.



Socket programming (1)

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.