UNIX Network Programming: Introduction to the UDP programming model

Source: Internet
Author: User

Some common applications written with UDP are: DNS (domain Name System), NFS (Network File system), and SNMP (Simple Network Management Protocol).

Instead of establishing a connection with the server, the client sends a datagram to the server using the SendTo function, which must specify the address of the destination (that is, the server) as an argument. Similarly, the server does not accept connections from customers, but instead calls the Recvfrom function, waiting for data from one customer to arrive. Recvfrom will return the client's protocol address with the received datagram, so the server can send the response to the correct customer.

For UDP, it is possible to write a data of length 0. In the case of UDP, this forms an IP datagram that contains only one IP header (typically 20 bytes for IPv4, typically 40 bytes for IPv6), and a 8-byte UDP header without data. This means that for datagram protocols, it is acceptable for recvfrom to return a value of 0: it does not represent a closed connection to the end as read on the TCP socket returns a value of 0. Since UDP is connectionless, there is no such thing as shutting down a UDP connection.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/unix/

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.