15.
The UNIX domain protocol is a way to perform client/server communications on a single host, using APIs that perform client/server communications on different hosts
UNIX domain sockets are typically one-fold faster than TCP sockets on the same host at both ends of the communication
UNIX domain sockets can be used to pass descriptors between different processes on the same host
A newer implementation of UNIX domain sockets provides the customer's credentials (user ID and group ID) to the server, providing additional security checks.
Socketpair Create two sockets that are subsequently concatenated
The default access permission for a pathname created by bind is an absolute path name
Descriptor Delivery:
After the fork call returns, the child process shares all open descriptors of the parent process
After the EXEC call executes, all descriptors are usually kept open
A special message is sent across sockets with SENDMSG, which is handled by the kernel and passes the open descriptor from the sending process to the receiving process.
Socketpair creates a stream pipeline that can be used to exchange descriptors between parent and child processes
The new descriptor and the one before the flight in the send process point to the same file table entry in the kernel
The advantage of the UNIX domain Word throttle socket is reflected in the performance growth.
16.
If you want to wait until a fixed number of data is readable, you can call our Readn function, or specify the Msg_waitall
For non-blocking sockets, if the input operation cannot be satisfied, the corresponding call will immediately return a ewouldblock error
Non-blocking connect will return a einprogress error
Whenever we find that non-blocking I/O is used, a simpler approach is usually to divide the application tasks into multiple processes or multithreading
POSIX: The descriptor becomes writable whenever the connection is successfully established. When an error is encountered, the descriptor becomes both readable and writable.
To determine whether a connection was successful:
1. Call Getpeername instead of getsocketopt
2. Call the read with a value of 0 length parameter
3. Connect one more time.
A simpler technique for avoiding portability is to create a processing thread for each connection.
For disconnected connect, you can only call the Select
Select is commonly used in conjunction with non-blocking I/O to determine when a descriptor can be read and writable.