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
fa34c520
Commit
fa34c520
authored
Jan 19, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
connect: try 3x
parent
b11afac0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
impl_unix.go
impl_unix.go
+19
-10
No files found.
impl_unix.go
View file @
fa34c520
...
...
@@ -106,18 +106,27 @@ func dial(dialer net.Dialer, netw, addr string) (c net.Conn, err error) {
}
}
if
fd
,
err
=
socket
(
rfamily
,
socktype
,
rprotocol
);
err
!=
nil
{
return
nil
,
err
}
// look at dialTCP in http://golang.org/src/net/tcpsock_posix.go .... !
// here we just try again 3 times.
for
i
:=
0
;
i
<
3
;
i
++
{
if
fd
,
err
=
socket
(
rfamily
,
socktype
,
rprotocol
);
err
!=
nil
{
return
nil
,
err
}
if
err
=
syscall
.
Bind
(
fd
,
localSockaddr
);
err
!=
nil
{
// fmt.Println("bind failed")
syscall
.
Close
(
fd
)
return
nil
,
err
if
err
=
syscall
.
Bind
(
fd
,
localSockaddr
);
err
!=
nil
{
// fmt.Println("bind failed")
syscall
.
Close
(
fd
)
return
nil
,
err
}
if
err
=
connect
(
fd
,
remoteSockaddr
);
err
!=
nil
{
syscall
.
Close
(
fd
)
// fmt.Println("connect failed", localSockaddr, err)
continue
// try again.
}
break
}
if
err
=
connect
(
fd
,
remoteSockaddr
);
err
!=
nil
{
syscall
.
Close
(
fd
)
// fmt.Println("connect failed", localSockaddr, err)
if
err
!=
nil
{
return
nil
,
err
}
...
...
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