Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Inter-process Communication based on TCP Protocol

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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))

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report