Commit dbf0f586 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Dial() func

parent 4db30cca
......@@ -3,6 +3,8 @@ package reuseport
import (
"errors"
"net"
resolve "github.com/jbenet/go-net-resolve-addr"
)
// ErrUnsuportedProtocol signals that the protocol is not currently
......@@ -19,6 +21,23 @@ func Listen(network, address string) (net.Listener, error) {
return listen(network, address)
}
// Dial dials the given network and address. see net.Dialer.Dial
// Returns a net.Conn created from a file discriptor for a socket
// with SO_REUSEPORT and SO_REUSEADDR option set.
func Dial(network, laddr, raddr string) (net.Conn, error) {
var d Dialer
if laddr != "" {
netladdr, err := resolve.ResolveAddr("dial", network, laddr)
if err != nil {
return nil, err
}
d.D.LocalAddr = netladdr
}
return dial(d.D, network, raddr)
}
// Dialer is used to specify the Dial options, much like net.Dialer.
// We simply wrap a net.Dialer.
type Dialer struct {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment