Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(288)

Delta Between Two Patch Sets: src/pkg/net/tcpsock_posix.go

Issue 8063043: code review 8063043: net: update documentation for ListenTCP, ListenUDP (Closed)
Left Patch Set: diff -r c879a45c3389 https://code.google.com/p/go Created 11 years, 11 months ago
Right Patch Set: diff -r 2433c3567273 https://code.google.com/p/go Created 11 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/tcpsock_plan9.go ('k') | src/pkg/net/udpsock_plan9.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd windows 5 // +build darwin freebsd linux netbsd openbsd windows
6 6
7 // TCP sockets 7 // TCP sockets
8 8
9 package net 9 package net
10 10
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 return syscall.EINVAL 265 return syscall.EINVAL
266 } 266 }
267 return setDeadline(l.fd, t) 267 return setDeadline(l.fd, t)
268 } 268 }
269 269
270 // File returns a copy of the underlying os.File, set to blocking mode. 270 // File returns a copy of the underlying os.File, set to blocking mode.
271 // It is the caller's responsibility to close f when finished. 271 // It is the caller's responsibility to close f when finished.
272 // Closing l does not affect f, and closing f does not affect l. 272 // Closing l does not affect f, and closing f does not affect l.
273 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() } 273 func (l *TCPListener) File() (f *os.File, err error) { return l.fd.dup() }
274 274
275 // ListenTCP announces on the TCP address laddr and returns a TCP 275 // ListenTCP announces on the TCP address laddr and returns a TCP
dave_cheney.net 2013/03/28 03:39:59 please see tcpsock_plan9.go
276 // listener. The net must be "tcp", "tcp4", or "tcp6". If laddr has 276 // listener. Net must be "tcp", "tcp4", or "tcp6". If laddr has a
277 // a port of 0, it means to listen on some available port. The caller 277 // port of 0, ListenTCP will choose an available port. The caller can
278 // can use Addr method on TCPListener to retrieve the chosen address. 278 // use the Addr method of TCPListener to retrieve the chosen address.
279 func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) { 279 func ListenTCP(net string, laddr *TCPAddr) (*TCPListener, error) {
280 switch net { 280 switch net {
281 case "tcp", "tcp4", "tcp6": 281 case "tcp", "tcp4", "tcp6":
282 default: 282 default:
283 return nil, UnknownNetworkError(net) 283 return nil, UnknownNetworkError(net)
284 } 284 }
285 if laddr == nil { 285 if laddr == nil {
286 laddr = &TCPAddr{} 286 laddr = &TCPAddr{}
287 } 287 }
288 fd, err := internetSocket(net, laddr.toAddr(), nil, noDeadline, syscall. SOCK_STREAM, 0, "listen", sockaddrToTCP) 288 fd, err := internetSocket(net, laddr.toAddr(), nil, noDeadline, syscall. SOCK_STREAM, 0, "listen", sockaddrToTCP)
289 if err != nil { 289 if err != nil {
290 return nil, err 290 return nil, err
291 } 291 }
292 err = syscall.Listen(fd.sysfd, listenerBacklog) 292 err = syscall.Listen(fd.sysfd, listenerBacklog)
293 if err != nil { 293 if err != nil {
294 closesocket(fd.sysfd) 294 closesocket(fd.sysfd)
295 return nil, &OpError{"listen", net, laddr, err} 295 return nil, &OpError{"listen", net, laddr, err}
296 } 296 }
297 return &TCPListener{fd}, nil 297 return &TCPListener{fd}, nil
298 } 298 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b