summaryrefslogtreecommitdiff
path: root/src/pkg/net/fd.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-12-02 15:17:49 -0800
committerRuss Cox <rsc@golang.org>2009-12-02 15:17:49 -0800
commitd1342b103e87acb0c1a57cb56996216b7c730989 (patch)
treec2278b29b1cf81b1d08b96cf4f854cf1a89c11f6 /src/pkg/net/fd.go
parentdc5302ce3674ac8bbc8dae9ab6ddb1c2aa107c54 (diff)
downloadgolang-d1342b103e87acb0c1a57cb56996216b7c730989.tar.gz
net: test and fix support for 0-length datagram packets.
Fixes issue 274. R=r CC=jonathan.r.hudson http://codereview.appspot.com/163072 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/net/fd.go')
-rw-r--r--src/pkg/net/fd.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pkg/net/fd.go b/src/pkg/net/fd.go
index e1592eb26..733f957e5 100644
--- a/src/pkg/net/fd.go
+++ b/src/pkg/net/fd.go
@@ -386,6 +386,10 @@ func (fd *netFD) Read(p []byte) (n int, err os.Error) {
}
break;
}
+ if fd.proto == syscall.SOCK_DGRAM && err == os.EOF {
+ // 0 in datagram protocol just means 0-length packet
+ err = nil
+ }
return;
}
@@ -433,7 +437,9 @@ func (fd *netFD) Write(p []byte) (n int, err os.Error) {
}
err = nil;
nn := 0;
- for nn < len(p) {
+ first := true; // force at least one Write, to send 0-length datagram packets
+ for nn < len(p) || first {
+ first = false;
n, err = fd.sysfile.Write(p[nn:]);
if n > 0 {
nn += n