Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
bd8e25ca
Commit
bd8e25ca
authored
Apr 30, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto-detect whether to use IPv6 or IPv4 kernel interface
R=r DELTA=12 (9 added, 0 deleted, 3 changed) OCL=28096 CL=28118
parent
10817ab9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
net.go
src/lib/net/net.go
+12
-3
No files found.
src/lib/net/net.go
View file @
bd8e25ca
...
...
@@ -300,9 +300,18 @@ func (c *connBase) SetLinger(sec int) os.Error {
// only dealing with IPv4 sockets? As long as the host system
// understands IPv6, it's okay to pass IPv4 addresses to the IPv6
// interface. That simplifies our code and is most general.
// If we need to build on a system without IPv6 support, setting
// preferIPv4 here should fall back to the IPv4 socket interface when possible.
const
preferIPv4
=
false
// Unfortunately, we need to run on kernels built without IPv6 support too.
// So probe the kernel to figure it out.
func
kernelSupportsIPv6
()
bool
{
fd
,
e
:=
syscall
.
Socket
(
syscall
.
AF_INET6
,
syscall
.
SOCK_STREAM
,
syscall
.
IPPROTO_TCP
);
if
fd
>=
0
{
syscall
.
Close
(
fd
)
}
return
e
==
0
}
var
preferIPv4
=
!
kernelSupportsIPv6
()
func
internetSocket
(
net
,
laddr
,
raddr
string
,
proto
int64
,
mode
string
)
(
fd
*
netFD
,
err
os
.
Error
)
...
...
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