What is the difference between socket communication and tcp communication?
The difference between socket communication and tcp communication: 1. The tcp protocol belongs to the transport layer protocol, while socket is an abstraction layer between the application layer and the transport layer; 2. A three-way handshake is required to establish a TCP connection; 3. Socket connections can maintain long connections; 4. TCP server and TCP client use socket communication, etc.
#The operating environment of this article: Windows 10 system, Dell G3 computer.
What is the difference between socket communication and tcp communication?
The difference between tcp and socket
## 1: tcp protocol
The tcp protocol belongs to the transport layer protocol (UDP also belongs to the transport layer protocol, but the UDP protocol is stateless). Establishing a TCP connection requires three handshakes, and disconnecting a TCP connection requires four waves. The mobile phone can use the networking function because the bottom layer of the mobile phone implements the TCP/IP protocol. You can use the mobile phone terminal to establish a TCP connection with the server through the wireless network. The TCP protocol can provide an interface to the upper-layer network, so that the transmission of upper-layer network data is established on an "undifferentiated" network. tcp requires three handshakes to establish a connection: Figure 1: Tcp connection three-way handshake diagram
Figure 2: Four wave waves when the tcp connection is disconnected
2: socket
We know that if two processes need to communicate, the most basic premise is to be able to uniquely identify a process. In local process communication, we can PID is used to uniquely identify a process, but PID is only unique locally. There is a high probability of PID conflict between two processes in the network. At this time, we need to find another way. We know that the IP address of the IP layer can uniquely identify the host, and The TCP layer protocol and port number can uniquely identify a process on the host, so we can use the IP address + protocol + port number to uniquely identify a process on the network. Figure 5: Schematic diagram of the socket communication system module
As you can see from the picture, the socket connection can maintain a long connection.
Figure 6: Basic socket client/server communication process diagram
Note that the socket connection can be actively closed by the client or the server.
For more related knowledge, please visit the FAQ column!
The above is the detailed content of What is the difference between socket communication and tcp communication?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver Mac version
Visual web development tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools
