Description =========== Named pipes on Win32 Synopsis ======== require "win32/pipe" include Win32 # In server.rb pserver = Pipe.new_server("foo") # Create a "foo" pipe server pserver.connect data = pserver.read puts "Got #{data} from client" pserver.close # In client.rb pclient = Pipe.new_client("foo") # Now, connect to "foo" pclient.write("Hello World") pclient.close Class Methods ============= Pipe.new_server(name,sync_type=Pipe::WAIT) Returns a new named pipe server instance. The 'sync_type' determines whether the server is blocking (WAIT) or non-blocking (NOWAIT). For now, only synchronous pipe servers are supported. Note that you do not need to include (nor should you) a "\\.\pipe\" at the front of the pipe name. It is automatically pre-pended for you. The pipe name is limited to 256 characters. Pipe.new_client(name) Returns a new named pipe instance and connects to 'name' automatically (i.e. you don't connect manually). If the 'name' pipe server doesn't exist already, a Win32PipeError is raised. Instance Methods ================ Pipe#close Closes and destroys the pipe. Pipe#connect Connects the server pipe, i.e. puts it in "connection wait" status. This is a server-only method. Pipe#read Reads data from the pipe. You can read data from either end of a named pipe. Pipe#write(data) Writes 'data' to the pipe. You can write data to either end of a named pipe. Constants ========= Standard Constants ------------------ VERSION Returns the current version number of this package as a String. Pipe Behavior Constants ----------------------- Pipe::WAIT Creates a blocking pipe. Pipe::NOWAIT Creates a non-blocking pipe (not yet supported). Exceptions ========== Win32PipeError Raised for pretty much any Pipe-specific errors. The most likely cause of this error is attempting to create a client when there's no equivalent server. Notes ===== This module is only supported on Windows NT, 2000 and XP. It won't work on Windows 95, 98 or ME. This package is an ALPHA release. I am considering changing the API to have separate Server and Client classes, perhaps as subclasses of a 'Pipe' superclass. Future Plans ============ * Add support for asynchronous pipes * Possible API change (this is an alpha release) * Add peek method * Add method to get pipe state * Add pipe transactions (?) * Allow remote mode changes on pipe servers (?) Acknowledgements ================ Thanks go to Park Heesob for spotting a bug in the write method. License ======= Ruby's Copyright ========= (C) 2003 Daniel J. Berger All Rights Reserved Author ====== Daniel J. Berger djberg96 at yahoo dot com rubyhacker1 on IRC