Add Dial and DialTimeout to the client api.

This is just to mimic net as much as possible.
This commit is contained in:
Miek Gieben 2013-11-01 09:40:44 +00:00
parent 39c7a972c3
commit d789796e53
1 changed files with 19 additions and 0 deletions

View File

@ -275,6 +275,25 @@ func (co *Conn) Write(p []byte) (n int, err error) {
return n, err
}
// Dial connects to the address on the named network.
func Dial(network, address string) (conn *Conn, err error) {
conn.Conn, err = net.Dial(network, address)
if err != nil {
return nil, err
}
return conn, nil
}
// Dialtimeout acts like Dial but takes a timeout.
func DialTimeout(network, address string, timeout time.Duration) (conn *Conn, err error) {
conn.Conn, err = net.DialTimeout(network, address, timeout)
if err != nil {
return nil, err
}
return conn, nil
}
// Close implements the net.Conn Close method.
func (co *Conn) Close() error { return co.Conn.Close() }