Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Inter-process Communication based on TCP Protocol

Shulou Source: shulou.com Published: 2022-06-01 05:18:40 09月27日 Update

TCP protocol is a protocol applied in the transport layer. Is a connection-oriented, reliable protocol.

Characteristics of TCP protocol:

1) oriented to byte stream.

2) TCP is a connection-oriented transport layer protocol

3) each TCP link can only have two endpoints

4) TCP provides reliable delivery of services

5) TCP provides full-duplex communication

According to the TCP protocol three-way handshake, server has been in the monitoring state, and so on to receive the client request connection (connect) signal, accept the connection.

Server: 1 # include 2 # include 3 # include 4 # include 5 # include 6 # include 7 # include 8 # include 9 # define _ BACKLOG 5 10 void usage (char * _ proc) 11 {12 printf ("usage:% s, [ip], [proc]", _ proc); 13} 14 int startup (const char * ip,const int port) 15 {16 int sock = socket (AF_INET,SOCK_STREAM,0) / / create socket 17 if (sock < 0) 18 {19 perror ("socket"); 20 exit (1); 21} 22 struct sockaddr_in local; 23 local.sin_family = AF_INET; 24 local.sin_port = htons (port); 25 local.sin_addr.s_addr = inet_addr (ip); 26 if (sock, (struct sockaddr*) & local,sizeof (local))

Tags: Processes communications two signals slogans sockets features states endpoints threads results links duplex transmission applications services monitoring transportation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux macOS Redmi Docker Xiaomi