可惜也没做过,试试看先登陆SERVER,还有就是SERVER端已经建了该PIPE了吗

解决方案 »

  1.   

    你这个createfile是什么呀CreateNamePipe(....
      

  2.   

    上面只贴了client端的,server端的如下:
    ssnpPipe=CreateNamedPipe("\\\\.\\PIPE\\ssnp",
                            PIPE_ACCESS_INBOUND,
          PIPE_TYPE_MESSAGE|PIPE_WAIT,
       1,100,100,0,
       (LPSECURITY_ATTRIBUTES) NULL);
    //Check and see if the named pipe was created
    if(ssnpPipe==INVALID_HANDLE_VALUE)
    {
    cerr<<"ERROR:Unableto create a named pipe."<<endl;
    return(1);
    }
    //Allow a client to connect to the name pipe,terminate if unsuccessful
    cout<<"Waiting for connection..."<<endl;
    if(!ConnectNamedPipe(ssnpPipe,(LPOVERLAPPED)NULL))
    {
    cerr<<"ERROR:Unable to connect a named pipe"<<GetLastError()<<endl;
    CloseHandle(ssnpPipe);
    return(1);
    }
    //Repeatedly check for messages until the programis terminated
    while(1)
    {
    //Read the message and check to see if read was successful
    if(!ReadFile(ssnpPipe,toDisptxt,sizeof(toDisptxt),
             &NumBytesRead,(LPOVERLAPPED) NULL))
    {
    cerr<<"ERROR:Unable to read from named pipe"
    <<GetLastError()<<endl;
    CloseHandle(ssnpPipe);
    return(1); }
    //display the Message
    cout<<toDisptxt<<endl;
    }//while
      

  3.   

    或者服务端用
    PIPE_ACCESS_DUPLEX看你的需要了。