VC ++ pipeline Communication

Source: Internet
Author: User
Tags readfile

I recently found a very depressing problem when I migrated the pipeline communication code to the C # program. Two standard clients and servers clearly showed the blocking mode in the help document, in addition, a group of people are searching for non-blocking mode, but according to the results of my debugging program, it is strange that even if overlapped is not specified, the program still returns real-time data in readfile and writefile, finally, we can see the following instructions:

 

Ii. Precautions for Program Design

1. If the named pipe client has been opened, the function will force the pipe to be closed, and the pipe to be closed with disconnectnamedpipe, the client must also use closehandle to close the final pipe.

2. The hfile handles of readfile and writefile are returned by createfile and connectnamedpipe.

3. A pipe handle that has been connected by a client before being connected by another client through connectnamedpipe, the server must use the disconnectnamedpipe function to forcibly detach an existing connection. Data in the MPs queue is lost when the server detaches the MPs queue. The flushfilebuffers function ensures that the data is not lost.

4. the named pipeline server can use the connectnamedpipe function through the newly created pipeline handle or the pipeline handle that has been connected to another customer, but before connecting to the new client, the server must use the disconnectnamedpipe function to cut off the customer handle. Otherwise, connectnamedpipe returns false.

5. blocking mode. This mode is only valid for the "Byte transmission pipeline" Operation and requires that the client and the server are not on the same machine. If this mode is used, data can be effectively returned only when the function successfully writes data to the remote computer pipeline buffer through the network. If this mode is not used, the system runs the default mode to improve network efficiency.

6. You must use file-create-pipe-instance to access the named pipe object. After a new named pipe is created, the access control list from security parameters defines the permission to access the named pipe. All named MPs queue instances must use the same MPs queue transmission mode, MPs queue mode, and other parameters. The client is not started, and the MPs Queue Server cannot perform read blocking operations. Otherwise, the client is in a blocking status such as null. When the last handle of the named pipe instance is closed, delete the named pipe.

 

 

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.