示例#1
0
func dial(addr string) (net.Conn, error) {
	conn, err := fasthttp.DialTimeout(addr, *httpClientRequestTimeout)
	if err != nil {
		return nil, err
	}
	if err = setupTCPConn(conn); err != nil {
		connError.Inc()
		conn.Close()
		return nil, err
	}

	connOpen.Inc()
	return &hostConn{
		Conn:         conn,
		addr:         addr,
		connOpen:     connOpen,
		readError:    readError,
		writeError:   writeError,
		bytesWritten: bytesWritten,
		bytesRead:    bytesRead,
	}, nil
}
示例#2
0
文件: fasthttp.go 项目: txrxio/planb
func dialWithTimeout(t time.Duration) func(string) (net.Conn, error) {
	return func(addr string) (net.Conn, error) {
		return fasthttp.DialTimeout(addr, t)
	}
}