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

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

Issue 6849045: code review 6849045: net, cmd/fix: add IPv6 scoped addressing zone to INET, ... (Closed)
Left Patch Set: diff -r fc4e67d82024 https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r c200281fac50 https://code.google.com/p/go Created 11 years, 4 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/multicast_posix_test.go ('k') | src/pkg/net/tcpsock_posix.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.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // TCP sockets
6
7 package net
8
9 import "time"
10
11 // TCPAddr represents the address of a TCP end point.
12 type TCPAddr struct { 1 type TCPAddr struct {
13 » IP IP 2 » IP IP
14 » Port int 3 » Port int
15 » ZoneId string // IPv6 scoped addressing zone identifier
16 } 4 }
17 5
18 // Network returns the address's network name, "tcp". 6 // Network returns the address's network name, "tcp".
19 func (a *TCPAddr) Network() string { return "tcp" }
20
21 func (a *TCPAddr) String() string {
22 if a == nil {
23 return "<nil>"
24 }
25 return JoinHostPort(a.IP.String(), itoa(a.Port))
26 }
27
28 // ResolveTCPAddr parses addr as a TCP address of the form
29 // host:port and resolves domain names or port names to
30 // numeric addresses on the network net, which must be "tcp",
31 // "tcp4" or "tcp6". A literal IPv6 host address must be
32 // enclosed in square brackets, as in "[::]:80".
33 func ResolveTCPAddr(net, addr string) (*TCPAddr, error) {
34 return resolveTCPAddr(net, addr, noDeadline)
35 }
36
37 func resolveTCPAddr(net, addr string, deadline time.Time) (*TCPAddr, error) {
38 ip, port, err := hostPortToIP(net, addr, deadline)
39 if err != nil {
40 return nil, err
41 }
42 return &TCPAddr{IP: ip, Port: port}, nil
43 }
LEFTRIGHT

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