func DialTimeout(address string, timeout time.Duration) (*PipeConn, error) {
	deadline := time.Now().Add(timeout)
	now := time.Now()
	for now.Before(deadline) {
		millis := uint32(deadline.Sub(now) / time.Millisecond)
		conn, err := dial(address, millis)
		if err == nil {
			return conn, nil
		}
		if err == error_sem_timeout {
			return nil, PipeError{fmt.Sprintf(
				"Timed out waiting for pipe '%s' to come available", address), true}
		}
		if isPipeNotReady(err) {
			left := deadline.Sub(time.Now())
			retry := 100 * time.Millisecond
			if left > retry {
				<-time.After(retry)
			} else {
				<-time.After(left - time.Millisecond)
			}
			now = time.Now()
			continue
		}
		return nil, err
	}
	return nil, PipeError{fmt.Sprintf(
		"Timed out waiting for pipe '%s' to come available", address), true}
}
DialTimeout acts like Dial, but will time out after the duration of timeout
package npipe
import (
	"fmt"
	"io"
	"net"
	"sync"
	"syscall"
	"time"
)
const (
	pipe_access_duplex   = 0x3
	pipe_access_inbound  = 0x1
	pipe_access_outbound = 0x2
	file_flag_first_pipe_instance = 0x00080000
	file_flag_write_through       = 0x80000000
	file_flag_overlapped          = 0x40000000
	write_dac              = 0x00040000
	write_owner            = 0x00080000
	access_system_security = 0x01000000
	pipe_type_byte    = 0x0
	pipe_type_message = 0x4
	pipe_readmode_byte    = 0x0
	pipe_readmode_message = 0x2
	pipe_wait   = 0x0
	pipe_nowait = 0x1
	pipe_accept_remote_clients = 0x0
	pipe_reject_remote_clients = 0x8
	pipe_unlimited_instances = 255
	nmpwait_wait_forever = 0xFFFFFFFF
	error_no_data        syscall.Errno = 0xE8
	error_pipe_connected syscall.Errno = 0x217
	error_pipe_busy      syscall.Errno = 0xE7
	error_sem_timeout    syscall.Errno = 0x79
	error_bad_pathname syscall.Errno = 0xA1
	error_invalid_name syscall.Errno = 0x7B
	error_io_incomplete  syscall.Errno = 0x3e4
	error_invalid_handle               = 0x6
)
var _ net.Conn = (*PipeConn)(nil)
var _ net.Listener = (*PipeListener)(nil)
var ErrClosed = PipeError{"Pipe has been closed.", false}
type PipeError struct {
	msg     string
	timeout bool
}
func (e PipeError) Error() string {
	return e.msg
}
func (e PipeError) Timeout() bool {
	return e.timeout
}
func (e PipeError) Temporary() bool {
	return false
}
func Dial(address string) (*PipeConn, error) {
	for {
		conn, err := dial(address, nmpwait_wait_forever)
		if err == nil {
			return conn, nil
		}
		if isPipeNotReady(err) {
			<-time.After(100 * time.Millisecond)
			continue
		}
		return nil, err
	}
}