朝伟's profileJackeyPhotosBlogLists Tools Help

Blog


    May 26

    Pipe

    pipe是一种进程间的通讯方式,因为它比较古老,也比较实用(没有DCOM或CORBA那么复杂),因此,在开源项目中被广泛应用(开源项目的思想就是要把复杂问题简单化)。

    Apache.exe 与 php.exe 的交互中使用了 pipe,由于与HTTP,CGI绑定得太紧密,没有搞懂。(C代码中任意使用函数指针,或许是造成代码无法阅读的重要原因。)

    WinCVS.exe 与 cvs.exe 的交互中使用了 pipe,基本上把这部分功能进行了独立,并且使用了C++那种特有的整合能力,因此,比较容易接受,进行移植后,达到了预期的目标。

    对照 Apache 与 WinCVS ,发现它们在 Win32 平台下的关于 pipe 的实现都参考了MSDN的一篇文章,再根据实际情况进行了调整。

    Creating a Child Process with Redirected Input and Output

    测试发现:Win32下面的 pipe 一次只能读取4096个字节,因此需要反复读取,直到遇到错误或没有读到任何数据为止。

    chunk => 块

    总的思想就是对数据区的一种定义,在各种不同的应用中有着各种不同的实现:

    在媒体文件中:rm,avi 中用一个结构来包容这个chunk。

    在HTTP协议中:用两行来表示 => 长度|内容,需要在前面用 Transfer-Encoding: chunk 来说明。

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://jackeyxp.spaces.live.com/blog/cns!38955632EAD9B1AD!116.trak
    Weblogs that reference this entry
    • None