In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Socketpair
Socketpair: compared to the previously mentioned pipeline, socketpair is a full-duplex communication mode, one end of which can be read or written. I understand it like this:
Suppose we are using socketpair locally, the client is fd [0] and the server is fd [1]. When the server writes data to the client, it writes data from the writer of fd [1] and reads the data from the reader of fd [1], and vice versa.
The following is an implementation of local interprocess communication for socketpair
# include / * See NOTES * / # include int socketpair (int domain, int type, int protocol, int sv [2])
Domian is the way to operate, so we use AF_LOCAL because we are local.
Type is the transmission mode, and we use tcp's streaming service, SOCK_STREAM.
For protocol control, we choose 0 by default.
Sv for how many file descriptors to create, note (this file descriptor is a network file descriptor, it can be said to be virtual).
1 # include 2 # include 3 # include 4 # include 5 # include 6 int main () 7 {8 int fd [2]; 9 if (socketpair (AF_LOCAL,SOCK_STREAM,0,fd) 0) 41 {42 buf [size] ='\ 0mm; 43 printf ("child say::%s\ n", buf) 44} 45 memset (buf,'\ 0buf, parent hello world); 46 strcpy (buf, "parent hello world"); 47 write (fd [0], buf,strlen (buf) + 1); 48} 49 close (fd [0]); 50 51} 52 53 return 0; 54}
Socketpair implements full-duplex communication.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.