Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions fcgiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package fcgiclient
import (
"bufio"
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
Expand Down Expand Up @@ -131,32 +132,26 @@ type FCGIClient struct {
reqId uint16
}

// Connects to the fcgi responder at the specified network address.
// See func net.Dial for a description of the network and address parameters.
func Dial(network, address string) (fcgi *FCGIClient, err error) {
var conn net.Conn

conn, err = net.Dial(network, address)
if err != nil {
return
}
// Dialer for this packages Dial* calls.
var Dialer = net.Dialer{}

fcgi = &FCGIClient{
rwc: conn,
keepAlive: false,
reqId: 1,
}

return
// Connects to the fcgi responder at the specified network address using `Dialer`.
func Dial(network, address string) (fcgi *FCGIClient, err error) {
return DialContext(context.Background(), network, address)
}

// Connects to the fcgi responder at the specified network address with timeout
// See func net.DialTimeout for a description of the network, address and timeout parameters.
// Connects to the fcgi responder at the specified network address using `Dialer` with timeout.
func DialTimeout(network, address string, timeout time.Duration) (fcgi *FCGIClient, err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
return DialContext(ctx, network, address)
}

// Connects to the fcgi responder at the specified network address using `Dialer` with context.
func DialContext(ctx context.Context, network, address string) (fcgi *FCGIClient, err error) {
var conn net.Conn

conn, err = net.DialTimeout(network, address, timeout)
conn, err = Dialer.DialContext(ctx, network, address)
if err != nil {
return
}
Expand Down