示例#1
0
func Dial(network, address string) (net.Conn, error) {
	if network == "npipe" {
		if !strings.HasPrefix(address, `\\.\pipe\`) {
			address = `\\.\pipe\` + address
		}
		return npipex.Dial(address)
	} else {
		return net.Dial(network, address)
	}
}
示例#2
0
// Use Dial to connect to a server and read messages from it.
func ExampleDial() {
	conn, err := npipex.Dial(`\\.\pipe\mypipe`)
	if err != nil {
		// handle error
	}
	if _, err := fmt.Fprintln(conn, "Hi server!"); err != nil {
		// handle error
	}
	r := bufio.NewReader(conn)
	msg, err := r.ReadString('\n')
	if err != nil {
		// handle eror
	}
	fmt.Println(msg)
}