vendor/gopkg.in/natefinch/npipe.v2/doc.go

50 lines · 1643 bytes

 1// Copyright 2013 Nate Finch. All rights reserved.
 2// Use of this source code is governed by an MIT-style
 3// license that can be found in the LICENSE file.
 4
 5// Package npipe provides a pure Go wrapper around Windows named pipes.
 6//
 7// !! Note, this package is Windows-only.  There is no code to compile on linux.
 8//
 9// Windows named pipe documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365780
10//
11// Note that the code lives at https://github.com/natefinch/npipe (v2 branch)
12// but should be imported as gopkg.in/natefinch/npipe.v2 (the package name is
13// still npipe).
14//
15// npipe provides an interface based on stdlib's net package, with Dial, Listen,
16// and Accept functions, as well as associated implementations of net.Conn and
17// net.Listener.  It supports rpc over the connection.
18//
19// Notes
20//
21// * Deadlines for reading/writing to the connection are only functional in Windows Vista/Server 2008 and above, due to limitations with the Windows API.
22//
23// * The pipes support byte mode only (no support for message mode)
24//
25// Examples
26//
27// The Dial function connects a client to a named pipe:
28//   conn, err := npipe.Dial(`\\.\pipe\mypipename`)
29//   if err != nil {
30//   	<handle error>
31//   }
32//   fmt.Fprintf(conn, "Hi server!\n")
33//   msg, err := bufio.NewReader(conn).ReadString('\n')
34//   ...
35//
36// The Listen function creates servers:
37//
38//   ln, err := npipe.Listen(`\\.\pipe\mypipename`)
39//   if err != nil {
40//   	// handle error
41//   }
42//   for {
43//   	conn, err := ln.Accept()
44//   	if err != nil {
45//   		// handle error
46//   		continue
47//   	}
48//   	go handleConnection(conn)
49//   }
50package npipe