UNIX Network Programming-15, 16 chapters-Summary __ programming

Source: Internet
Author: User
Tags readable

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.