Socket programming 2: tcp, udp, and socketudp

Source: Internet
Author: User

Socket programming 2: tcp, udp, and socketudp

In the previous article, I talked about some basic knowledge about computer networks and introduced socket. From this section, I started to get started.


1 Probability

TCP: Transimission Control Protocol Transmission Control Protocol.

UPD: User datav Protocol User data packet Protocol.

Both belong to the transport layer protocol, the fourth layer in the OSI model described in the previous article.

Comparison:

  1. TCP is connection-oriented, and UDP is non-connection-oriented)
  2. Slow TCP transmission speed and fast UDP transmission speed)
  3. TCP has a packet loss retransmission mechanism, but UDP does not; (Retransmission)
  4. TCP ensures data correctness and UDP may cause packet loss (correctness)
  5. TCP is suitable for transmitting a large amount of data, and UPD is suitable for transmitting a small amount of data. (Data volume)
2. TCP link Process

3. UDP Link

* Both images are from the network.

Socket programming

Socket is an API for TCP/IP networks. programmers use socket interfaces to exchange data.



What is the relationship between SOCKET and TCP and UDP?

SOCKET is an API for Java to implement data communication.
This term originated from BSD-related UNIX and is the name of the API used for communication between processes in program development.

TCP/UDP is the two communication modes defined in Layer 4 of the OSI model.

That is to say, SOCKET is an API, and TCP/UPD is a communication protocol. The two are fundamentally different.

Example of language expression:
Use SOCKET to implement TCP (or UDP) communication. (On the contrary, TCP or UDP communication can also be implemented without SOCKET)

Differences between Socket and TCP/IP Programming

A Socket interface is an API of a TCP/IP network. A Socket interface defines many functions or routines that can be used by programmers to develop applications on a TCP/IP network. To learn TCP/IP network programming on the Internet, you must understand the Socket interface.
Socket is also a file descriptor. You can write IP addresses and port numbers to establish TCP/UDP connections.
It's easy to learn about socket. You can look at Windows network programming.

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.