Windows和linux管道通讯有关问题

Windows和linux管道通讯问题
linux 机器IP地址192.168.0.187 建立管道服务端\\.\Pipe\pipeserver
另台机器Windows下建立管道客户端\\192.168.0.187\Pipe\pipeserver
windows下WaitNamedPipe失败,怎么回事

------解决方案--------------------
管道是Windows和Unix系统都提供的一种进程间通信方式。管道分为两种:匿名管道与命名管道。匿名管道一般用于进程内通信,而进程间通信则可以使用命名管道,同时命名管道也用于多台计算机之间进行通信。对于命名管道,只有Windows NT 3.1后的版本才支持,比如Windows NT 4,Windows 2000,而Windows 95/98并不支持。
管道的使用包括创建管道,读写管道,以及关闭管道。Microsoft将管道的读写过程看作是文件的读写过程,即将管道作为文件来处理。文件的读写在Win32中可以使用ReadFile/WriteFile、ReadFileEx/WriteFileEx函数来实现。

------解决方案--------------------
Named Pipes
A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client-server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously. 

Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes. Named pipes can be used to provide communication between processes on the same computer or between processes on different computers across a network. 

Any process can act as both a server and a client, making peer-to-peer communication possible. As used here, the term pipe server refers to a process that creates a named pipe, and the term pipe client refers to a process that connects to an instance of a named pipe. 

 

------解决方案--------------------
Pipe Functions
The following functions are used with pipes. 

  
 
CallNamedPipe
ConnectNamedPipe
CreateNamedPipe
CreatePipe
DisconnectNamedPipe
GetNamedPipeHandleState
GetNamedPipeInfo
PeekNamedPipe
SetNamedPipeHandleState
TransactNamedPipe
WaitNamedPipe


 

------解决方案--------------------
Named Pipes
This section describes limitations and problems involving the use of named pipes in Windows NT 3.5.

To upgrade from Windows for Workgroups to Windows NT 3.5, installing IPX/SPX protocol in addition to NetBEUI protocol, you need to install a new VREDIR.386, which is available on the Windows NT Server CD in \clients\wfw\update\vredir.386.

Make sure the default frame type is correct. It has been changed from ethernet_802.3 to ethernet_802.2. If you are using 802.3, you need to change the following entry in the protocol.ini under the [nwlink] section:

FRAME=ETHERNET_802.3

Windows NT Server 3.5 can support a maximum of 512 named pipes. Each SNA Server client uses two named pipes, so you can run out of SMB server resources at around 250 clients if you are using named pipes as the transport. The 20xx events in the Event Log typically result from SMB running out of these MaxWorkItem resources.

The maximum is raised to 4096 in Windows NT Server 3.51, and the SNA Server 2.11 automatically sets this entry to 4096. The default is still set to 512 if you are running SNA Server 2.1 on Windows NT 3.51, so you'll have to manually change this parameter. There are some other improvements in SNA Server 2.11, including not having to log on twice, so you should upgrade to it.

It would be a good idea to switch to sockets from named pipes for several reasons:

• TCP/IP or IPX connections don't have the resource limitation described here
• You can get up to a 30 percent improvement in performance
• Negotiating a session with sockets takes one third less traffic on the network compared to using named pipes
• Named pipes consume quite a bit more memory on the server