Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-reuseport
Commits
dbf0f586
Commit
dbf0f586
authored
Jan 18, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dial() func
parent
4db30cca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
interface.go
interface.go
+19
-0
No files found.
interface.go
View file @
dbf0f586
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment