mirror of
https://github.com/golang/go
synced 2024-11-22 09:04:42 -07:00
i can import "net" in package net
and still have a variable named "net" R=r DELTA=18 (0 added, 0 deleted, 18 changed) OCL=16220 CL=16222
This commit is contained in:
parent
1f1ae404f8
commit
a4f15640aa
@ -279,7 +279,7 @@ func (c *ConnBase) SetLinger(sec int) *os.Error {
|
|||||||
// PreferIPv4 here should fall back to the IPv4 socket interface when possible.
|
// PreferIPv4 here should fall back to the IPv4 socket interface when possible.
|
||||||
const PreferIPv4 = false
|
const PreferIPv4 = false
|
||||||
|
|
||||||
func InternetSocket(netw, laddr, raddr string, proto int64) (fd *FD, err *os.Error) {
|
func InternetSocket(net, laddr, raddr string, proto int64) (fd *FD, err *os.Error) {
|
||||||
// Parse addresses (unless they are empty).
|
// Parse addresses (unless they are empty).
|
||||||
var lip, rip *[]byte
|
var lip, rip *[]byte
|
||||||
var lport, rport int
|
var lport, rport int
|
||||||
@ -292,13 +292,13 @@ rport = 0;
|
|||||||
lerr = nil;
|
lerr = nil;
|
||||||
rerr = nil
|
rerr = nil
|
||||||
if laddr != "" {
|
if laddr != "" {
|
||||||
lip, lport, lerr = HostPortToIP(netw, laddr)
|
lip, lport, lerr = HostPortToIP(net, laddr)
|
||||||
if lerr != nil {
|
if lerr != nil {
|
||||||
return nil, lerr
|
return nil, lerr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if raddr != "" {
|
if raddr != "" {
|
||||||
rip, rport, rerr = HostPortToIP(netw, raddr)
|
rip, rport, rerr = HostPortToIP(net, raddr)
|
||||||
if rerr != nil {
|
if rerr != nil {
|
||||||
return nil, rerr
|
return nil, rerr
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ rerr = nil
|
|||||||
// Figure out IP version.
|
// Figure out IP version.
|
||||||
// If network has a suffix like "tcp4", obey it.
|
// If network has a suffix like "tcp4", obey it.
|
||||||
vers := 0;
|
vers := 0;
|
||||||
switch netw[len(netw)-1] {
|
switch net[len(net)-1] {
|
||||||
case '4':
|
case '4':
|
||||||
vers = 4
|
vers = 4
|
||||||
case '6':
|
case '6':
|
||||||
@ -429,11 +429,11 @@ func NewConnTCP(fd *FD, raddr string) *ConnTCP {
|
|||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
export func DialTCP(netw, laddr, raddr string) (c *ConnTCP, err *os.Error) {
|
export func DialTCP(net, laddr, raddr string) (c *ConnTCP, err *os.Error) {
|
||||||
if raddr == "" {
|
if raddr == "" {
|
||||||
return nil, MissingAddress
|
return nil, MissingAddress
|
||||||
}
|
}
|
||||||
fd, e := InternetSocket(netw, laddr, raddr, syscall.SOCK_STREAM)
|
fd, e := InternetSocket(net, laddr, raddr, syscall.SOCK_STREAM)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e
|
||||||
}
|
}
|
||||||
@ -496,26 +496,26 @@ var noconn NoConn
|
|||||||
// Eventually, we plan to allow names in addition to IP addresses,
|
// Eventually, we plan to allow names in addition to IP addresses,
|
||||||
// but that requires writing a DNS library.
|
// but that requires writing a DNS library.
|
||||||
|
|
||||||
export func Dial(netw, laddr, raddr string) (c Conn, err *os.Error) {
|
export func Dial(net, laddr, raddr string) (c Conn, err *os.Error) {
|
||||||
switch netw {
|
switch net {
|
||||||
case "tcp", "tcp4", "tcp6":
|
case "tcp", "tcp4", "tcp6":
|
||||||
c, err := DialTCP(netw, laddr, raddr)
|
c, err := DialTCP(net, laddr, raddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &noconn, err
|
return &noconn, err
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
/*
|
/*
|
||||||
case "udp", "udp4", "upd6":
|
case "udp", "udp4", "upd6":
|
||||||
c, err := DialUDP(netw, laddr, raddr)
|
c, err := DialUDP(net, laddr, raddr)
|
||||||
return c, err
|
return c, err
|
||||||
case "ether":
|
case "ether":
|
||||||
c, err := DialEther(netw, laddr, raddr)
|
c, err := DialEther(net, laddr, raddr)
|
||||||
return c, err
|
return c, err
|
||||||
case "ipv4":
|
case "ipv4":
|
||||||
c, err := DialIPv4(netw, laddr, raddr)
|
c, err := DialIPv4(net, laddr, raddr)
|
||||||
return c, err
|
return c, err
|
||||||
case "ipv6":
|
case "ipv6":
|
||||||
c, err := DialIPv6(netw, laddr, raddr)
|
c, err := DialIPv6(net, laddr, raddr)
|
||||||
return c, err
|
return c, err
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -541,8 +541,8 @@ export type ListenerTCP struct {
|
|||||||
laddr string
|
laddr string
|
||||||
}
|
}
|
||||||
|
|
||||||
export func ListenTCP(netw, laddr string) (l *ListenerTCP, err *os.Error) {
|
export func ListenTCP(net, laddr string) (l *ListenerTCP, err *os.Error) {
|
||||||
fd, e := InternetSocket(netw, laddr, "", syscall.SOCK_STREAM)
|
fd, e := InternetSocket(net, laddr, "", syscall.SOCK_STREAM)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e
|
||||||
}
|
}
|
||||||
@ -588,10 +588,10 @@ func (l *ListenerTCP) Close() *os.Error {
|
|||||||
return l.fd.Close()
|
return l.fd.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
export func Listen(netw, laddr string) (l Listener, err *os.Error) {
|
export func Listen(net, laddr string) (l Listener, err *os.Error) {
|
||||||
switch netw {
|
switch net {
|
||||||
case "tcp", "tcp4", "tcp6":
|
case "tcp", "tcp4", "tcp6":
|
||||||
l, err := ListenTCP(netw, laddr)
|
l, err := ListenTCP(net, laddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &nolistener, err
|
return &nolistener, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user