注意ACE_Pipe的實現(xiàn)

字號:

ACE_Pipe是一個跨平臺的管道實現(xiàn)。標(biāo)準(zhǔn)情況來講,采用的實現(xiàn),但是在的兩個平臺Windows和Linux上,ACE的實現(xiàn)是采用的Socket實現(xiàn)。
    int
    ACE_Pipe::open (int buffer_size)
    {
    ACE_TRACE ("ACE_Pipe::open");
    #if defined (ACE_LACKS_SOCKETPAIR) || defined (__Lynx__)
    //綁定了一個本地端口,0.0.0.0,然后找到相應(yīng)的端口,用于后面的鏈接
    if (acceptor.open (local_any) == -1
    || acceptor.get_local_addr (my_addr) == -1)
    result = -1;
    else
    {
    // Establish a connection within the same process.
    if (connector.connect (writer, sv_addr) == -1)
    result = -1;
    ……
    所以很多管道特性所特有的東西,在這兩個平臺上是無法使用ACE_Pipe實現(xiàn)的。比如,管道的特性可以保證在暫時沒有接受者的情況下使用,而Socket是不可能有這個特性的。你必須保證先有接受者,后有發(fā)送者的時序。
    所以在這些平臺上不用這個封裝。