Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
5ee02eef
Commit
5ee02eef
authored
Jul 26, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: TCPConn.SetNoDelay, back by popular demand
R=r CC=golang-dev
https://golang.org/cl/1880047
parent
4188504f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
src/pkg/net/sock.go
src/pkg/net/sock.go
+6
-0
src/pkg/net/tcpsock.go
src/pkg/net/tcpsock.go
+12
-1
No files found.
src/pkg/net/sock.go
View file @
5ee02eef
...
...
@@ -129,6 +129,12 @@ func setKeepAlive(fd *netFD, keepalive bool) os.Error {
return
setsockoptInt
(
fd
.
sysfd
,
syscall
.
SOL_SOCKET
,
syscall
.
SO_KEEPALIVE
,
boolint
(
keepalive
))
}
func
setNoDelay
(
fd
*
netFD
,
noDelay
bool
)
os
.
Error
{
fd
.
incref
()
defer
fd
.
decref
()
return
setsockoptInt
(
fd
.
sysfd
,
syscall
.
IPPROTO_TCP
,
syscall
.
TCP_NODELAY
,
boolint
(
noDelay
))
}
func
setLinger
(
fd
*
netFD
,
sec
int
)
os
.
Error
{
var
l
syscall
.
Linger
if
sec
>=
0
{
...
...
src/pkg/net/tcpsock.go
View file @
5ee02eef
...
...
@@ -73,7 +73,7 @@ type TCPConn struct {
func
newTCPConn
(
fd
*
netFD
)
*
TCPConn
{
c
:=
&
TCPConn
{
fd
}
setsockoptInt
(
fd
.
sysfd
,
syscall
.
IPPROTO_TCP
,
syscall
.
TCP_NODELAY
,
1
)
c
.
SetNoDelay
(
true
)
return
c
}
...
...
@@ -192,6 +192,17 @@ func (c *TCPConn) SetKeepAlive(keepalive bool) os.Error {
return
setKeepAlive
(
c
.
fd
,
keepalive
)
}
// SetNoDelay controls whether the operating system should delay
// packet transmission in hopes of sending fewer packets
// (Nagle's algorithm). The default is true (no delay), meaning
// that data is sent as soon as possible after a Write.
func
(
c
*
TCPConn
)
SetNoDelay
(
noDelay
bool
)
os
.
Error
{
if
!
c
.
ok
()
{
return
os
.
EINVAL
}
return
setNoDelay
(
c
.
fd
,
noDelay
)
}
// DialTCP is like Dial but can only connect to TCP networks
// and returns a TCPConn structure.
func
DialTCP
(
net
string
,
laddr
,
raddr
*
TCPAddr
)
(
c
*
TCPConn
,
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