Lines Matching refs:network
42 // network being dialed.
47 // dialing when the network is "tcp" and the host in the
59 // network connection.
60 // If zero, keep-alives are not enabled. Network protocols
139 func parseNetwork(ctx context.Context, network string, needsProto bool) (afnet string, proto int, err error) {
140 i := last(network, ':')
142 switch network {
147 return "", 0, UnknownNetworkError(network)
151 return "", 0, UnknownNetworkError(network)
153 return network, 0, nil
155 afnet = network[:i]
158 protostr := network[i+1:]
168 return "", 0, UnknownNetworkError(network)
174 func (r *Resolver) resolveAddrList(ctx context.Context, op, network, addr string, hint Addr) (addrList, error) {
175 afnet, _, err := parseNetwork(ctx, network, true)
188 if op == "dial" && hint != nil && addr.Network() != hint.Network() {
216 if addr.Network() != hint.Network() {
243 // Dial connects to the address on the named network.
271 // For IP networks, the network must be "ip", "ip4" or "ip6" followed
289 func Dial(network, address string) (Conn, error) {
291 return d.Dial(network, address)
302 // See func Dial for a description of the network and address
304 func DialTimeout(network, address string, timeout time.Duration) (Conn, error) {
306 return d.Dial(network, address)
312 network, address string
315 // Dial connects to the address on the named network.
317 // See func Dial for a description of the network and address
319 func (d *Dialer) Dial(network, address string) (Conn, error) {
320 return d.DialContext(context.Background(), network, address)
323 // DialContext connects to the address on the named network using
332 // network addresses, any dial timeout (from d.Timeout or ctx) is spread
339 // See func Dial for a description of the network and address
341 func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn, error) {
375 addrs, err := d.resolver().resolveAddrList(resolveCtx, "dial", network, address, d.LocalAddr)
377 return nil, &OpError{Op: "dial", Net: network, Source: nil, Addr: nil, Err: err}
382 network: network,
387 if d.DualStack && network == "tcp" {
495 return nil, &OpError{Op: "dial", Net: dp.network, Source: dp.LocalAddr, Addr: ra, Err: mapErr(ctx.Err())}
504 firstErr = &OpError{Op: "dial", Net: dp.network, Source: dp.LocalAddr, Addr: ra, Err: err}
525 firstErr = &OpError{Op: "dial", Net: dp.network, Source: nil, Addr: nil, Err: errMissingAddress}
537 trace.ConnectStart(dp.network, raStr)
540 defer func() { trace.ConnectDone(dp.network, raStr, err) }()
547 c, err = dialTCP(ctx, dp.network, la, ra)
550 c, err = dialUDP(ctx, dp.network, la, ra)
553 c, err = dialIP(ctx, dp.network, la, ra)
556 c, err = dialUnix(ctx, dp.network, la, ra)
558 return nil, &OpError{Op: "dial", Net: dp.network
561 return nil, &OpError{Op: "dial", Net: dp.network, Source: la, Addr: ra, Err: err} // c is non-nil interface containing nil pointer
566 // Listen announces on the local network address.
568 // The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
573 // To only use IPv4, use network "tcp4".
582 // See func Dial for a description of the network and address
584 func Listen(network, address string) (Listener, error) {
585 addrs, err := DefaultResolver.resolveAddrList(context.Background(), "listen", network, address, nil)
587 return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: nil, Err: err}
592 l, err = ListenTCP(network, la)
594 l, err = ListenUnix(network, la)
596 return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: la, Err: &AddrError{Err: "unexpected address type", Addr: address}}
604 // ListenPacket announces on the local network address.
606 // The network must be "udp", "udp4", "udp6", "unixgram", or an IP
615 // To only use IPv4, use network "udp4" or "ip4:proto".
624 // See func Dial for a description of the network and address
626 func ListenPacket(network, address string) (PacketConn, error) {
627 addrs, err := DefaultResolver.resolveAddrList(context.Background(), "listen", network, address, nil)
629 return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: nil, Err: err}
634 l, err = ListenUDP(network, la)
636 l, err = ListenIP(network, la)
638 l, err = ListenUnixgram(network, la)
640 return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: la, Err: &AddrError{Err: "unexpected address type", Addr: address}}