In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Creating a socket: Everything in UNIX is a file socket system call to create a socketint socket (int domain, int type, int protocol);domain: tells the system which underlying protocol family to use type: specifies the service type 1.1 The service types are SOCK_STREAM and SOCK_UGRAM1. The kernel starts at 2.16.17, and the type can be followed by the logical AND parameters SOCK_NONBLOCK and SOCK_CLOEXEC to indicate whether the socket is non-blocking 1.3 protocol parameters Under the first two parameters, select a specific protocol invocation result: Returns a socket file descriptor, failure returns-1 and sets errno2. Named socket creation, we only specified the address family, but did not specify the specific socket address to use to speak a socket and socket address binding called socket naming server needs to name socket, the client does not need 2.1int bind (int sockfd,const struct sockaddr * my_addr,socklen_t addrlen);
bind successfully returns 0, fails returns-1 and sets errno
2.2 Common failures are EACCES: the bound address is protected and only superusers can access it.
EADDRINUSE: bound address in use
3. listening socket,
After creation and naming, it cannot be directly accessed by clients. A listening queue needs to be created to store pending client connections.
3.1 int listen(int sockfd, int backlog);
The backlog parameter indicates the maximum length of the kernel listening queue
After that, customer connections will no longer be accepted
The error message is ECONNREFUSED.
listen singing returns 0, failure returns-1 and errno is set
Full connections are only backlog+1
4. accept connections
int accept(int sockfd,struct sockaddr addr,socklen_t addrlen)
Question: What happens if a client requests a network anomaly or a drop?
Answer: accept only takes connections from the listening queue, regardless of the state of the connection, and does not care about network changes
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.