X7ROOT File Manager
Current Path:
/opt/golang/1.17.2/src/net
opt
/
golang
/
1.17.2
/
src
/
net
/
📁
..
📄
addrselect.go
(9.59 KB)
📄
addrselect_test.go
(6.28 KB)
📄
cgo_aix.go
(603 B)
📄
cgo_android.go
(293 B)
📄
cgo_bsd.go
(419 B)
📄
cgo_linux.go
(672 B)
📄
cgo_netbsd.go
(297 B)
📄
cgo_openbsd.go
(297 B)
📄
cgo_resnew.go
(668 B)
📄
cgo_resold.go
(654 B)
📄
cgo_socknew.go
(816 B)
📄
cgo_sockold.go
(937 B)
📄
cgo_solaris.go
(364 B)
📄
cgo_stub.go
(1.08 KB)
📄
cgo_unix.go
(9.65 KB)
📄
cgo_unix_test.go
(2.01 KB)
📄
cgo_windows.go
(423 B)
📄
conf.go
(8.78 KB)
📄
conf_netcgo.go
(387 B)
📄
conf_test.go
(9.76 KB)
📄
conn_test.go
(1.79 KB)
📄
dial.go
(22.72 KB)
📄
dial_test.go
(26.02 KB)
📄
dial_unix_test.go
(2.83 KB)
📄
dnsclient.go
(5.73 KB)
📄
dnsclient_test.go
(1.51 KB)
📄
dnsclient_unix.go
(22.12 KB)
📄
dnsclient_unix_test.go
(54.46 KB)
📄
dnsconfig_unix.go
(5.56 KB)
📄
dnsconfig_unix_test.go
(6.83 KB)
📄
dnsname_test.go
(1.99 KB)
📄
error_plan9.go
(224 B)
📄
error_plan9_test.go
(398 B)
📄
error_posix.go
(700 B)
📄
error_posix_test.go
(998 B)
📄
error_test.go
(19.59 KB)
📄
error_unix.go
(517 B)
📄
error_unix_test.go
(702 B)
📄
error_windows.go
(355 B)
📄
error_windows_test.go
(483 B)
📄
example_test.go
(3.88 KB)
📄
external_test.go
(4.08 KB)
📄
fcntl_libc_test.go
(400 B)
📄
fcntl_syscall_test.go
(545 B)
📄
fd_plan9.go
(3.56 KB)
📄
fd_posix.go
(2.58 KB)
📄
fd_unix.go
(5.54 KB)
📄
fd_windows.go
(4.62 KB)
📄
file.go
(1.69 KB)
📄
file_plan9.go
(2.68 KB)
📄
file_stub.go
(507 B)
📄
file_test.go
(6.55 KB)
📄
file_unix.go
(2.6 KB)
📄
file_windows.go
(521 B)
📄
hook.go
(628 B)
📄
hook_plan9.go
(283 B)
📄
hook_unix.go
(840 B)
📄
hook_windows.go
(875 B)
📄
hosts.go
(3.1 KB)
📄
hosts_test.go
(4.59 KB)
📁
http
📄
interface.go
(7.17 KB)
📄
interface_aix.go
(4.41 KB)
📄
interface_bsd.go
(2.8 KB)
📄
interface_bsd_test.go
(1.48 KB)
📄
interface_bsdvar.go
(753 B)
📄
interface_darwin.go
(1.29 KB)
📄
interface_freebsd.go
(1.42 KB)
📄
interface_linux.go
(6.9 KB)
📄
interface_linux_test.go
(3.65 KB)
📄
interface_plan9.go
(4.68 KB)
📄
interface_solaris.go
(2.07 KB)
📄
interface_stub.go
(830 B)
📄
interface_test.go
(9.68 KB)
📄
interface_unix_test.go
(4.79 KB)
📄
interface_windows.go
(5.41 KB)
📁
internal
📄
ip.go
(17.66 KB)
📄
ip_test.go
(25.33 KB)
📄
iprawsock.go
(7.08 KB)
📄
iprawsock_plan9.go
(874 B)
📄
iprawsock_posix.go
(3.56 KB)
📄
iprawsock_test.go
(5.63 KB)
📄
ipsock.go
(8.97 KB)
📄
ipsock_plan9.go
(7.5 KB)
📄
ipsock_plan9_test.go
(645 B)
📄
ipsock_posix.go
(6.28 KB)
📄
ipsock_test.go
(6.81 KB)
📄
listen_test.go
(21.34 KB)
📄
lookup.go
(21.33 KB)
📄
lookup_fake.go
(1.66 KB)
📄
lookup_plan9.go
(7.68 KB)
📄
lookup_test.go
(31.13 KB)
📄
lookup_unix.go
(8.89 KB)
📄
lookup_windows.go
(11.72 KB)
📄
lookup_windows_test.go
(8.02 KB)
📄
mac.go
(1.88 KB)
📄
mac_test.go
(3.26 KB)
📁
mail
📄
main_cloexec_test.go
(750 B)
📄
main_conf_test.go
(952 B)
📄
main_noconf_test.go
(537 B)
📄
main_plan9_test.go
(392 B)
📄
main_posix_test.go
(1.4 KB)
📄
main_test.go
(7.13 KB)
📄
main_unix_test.go
(1.33 KB)
📄
main_windows_test.go
(1.08 KB)
📄
mockserver_test.go
(11.39 KB)
📄
net.go
(22.37 KB)
📄
net_fake.go
(5.37 KB)
📄
net_test.go
(13.88 KB)
📄
net_windows_test.go
(15.94 KB)
📄
netgo_unix_test.go
(741 B)
📄
nss.go
(3.8 KB)
📄
nss_test.go
(3.42 KB)
📄
packetconn_test.go
(3.57 KB)
📄
parse.go
(7.33 KB)
📄
parse_test.go
(2.14 KB)
📄
pipe.go
(5.43 KB)
📄
pipe_test.go
(1.2 KB)
📄
platform_test.go
(4.57 KB)
📄
port.go
(1.46 KB)
📄
port_test.go
(1.34 KB)
📄
port_unix.go
(1.39 KB)
📄
protoconn_test.go
(7.24 KB)
📄
rawconn.go
(1.89 KB)
📄
rawconn_stub_test.go
(655 B)
📄
rawconn_test.go
(4.45 KB)
📄
rawconn_unix_test.go
(3.1 KB)
📄
rawconn_windows_test.go
(3.12 KB)
📁
rpc
📄
sendfile_linux.go
(1.1 KB)
📄
sendfile_stub.go
(391 B)
📄
sendfile_test.go
(6.91 KB)
📄
sendfile_unix_alt.go
(2.02 KB)
📄
sendfile_windows.go
(1.02 KB)
📄
server_test.go
(11.11 KB)
📁
smtp
📄
sock_bsd.go
(968 B)
📄
sock_cloexec.go
(1.53 KB)
📄
sock_linux.go
(1.53 KB)
📄
sock_linux_test.go
(545 B)
📄
sock_plan9.go
(262 B)
📄
sock_posix.go
(6.92 KB)
📄
sock_stub.go
(420 B)
📄
sock_windows.go
(1.16 KB)
📄
sockaddr_posix.go
(1.05 KB)
📄
sockopt_aix.go
(1.43 KB)
📄
sockopt_bsd.go
(2.26 KB)
📄
sockopt_linux.go
(1.25 KB)
📄
sockopt_plan9.go
(406 B)
📄
sockopt_posix.go
(2.76 KB)
📄
sockopt_solaris.go
(1.25 KB)
📄
sockopt_stub.go
(760 B)
📄
sockopt_windows.go
(1.51 KB)
📄
sockoptip_bsdvar.go
(929 B)
📄
sockoptip_linux.go
(735 B)
📄
sockoptip_posix.go
(1.53 KB)
📄
sockoptip_stub.go
(971 B)
📄
sockoptip_windows.go
(819 B)
📄
splice_linux.go
(1.09 KB)
📄
splice_stub.go
(304 B)
📄
splice_test.go
(10.51 KB)
📄
sys_cloexec.go
(1 KB)
📄
tcpsock.go
(9.88 KB)
📄
tcpsock_plan9.go
(2.13 KB)
📄
tcpsock_posix.go
(5.39 KB)
📄
tcpsock_test.go
(17.53 KB)
📄
tcpsock_unix_test.go
(2.41 KB)
📄
tcpsockopt_darwin.go
(770 B)
📄
tcpsockopt_dragonfly.go
(698 B)
📄
tcpsockopt_openbsd.go
(365 B)
📄
tcpsockopt_plan9.go
(525 B)
📄
tcpsockopt_posix.go
(592 B)
📄
tcpsockopt_solaris.go
(1.15 KB)
📄
tcpsockopt_stub.go
(415 B)
📄
tcpsockopt_unix.go
(757 B)
📄
tcpsockopt_windows.go
(741 B)
📁
testdata
📁
textproto
📄
timeout_test.go
(23.39 KB)
📄
udpsock.go
(9.19 KB)
📄
udpsock_plan9.go
(3.79 KB)
📄
udpsock_plan9_test.go
(1.31 KB)
📄
udpsock_posix.go
(4.27 KB)
📄
udpsock_test.go
(12.27 KB)
📄
unixsock.go
(10.17 KB)
📄
unixsock_linux_test.go
(2.29 KB)
📄
unixsock_plan9.go
(1.24 KB)
📄
unixsock_posix.go
(6.03 KB)
📄
unixsock_readmsg_cloexec.go
(691 B)
📄
unixsock_readmsg_cmsg_cloexec.go
(373 B)
📄
unixsock_readmsg_other.go
(301 B)
📄
unixsock_readmsg_test.go
(2.62 KB)
📄
unixsock_test.go
(10.56 KB)
📄
unixsock_windows_test.go
(2.09 KB)
📁
url
📄
write_unix_test.go
(1.67 KB)
📄
writev_test.go
(5.02 KB)
📄
writev_unix.go
(797 B)
Editing: unixsock.go
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package net import ( "context" "os" "sync" "syscall" "time" ) // BUG(mikio): On JS and Plan 9, methods and functions related // to UnixConn and UnixListener are not implemented. // BUG(mikio): On Windows, methods and functions related to UnixConn // and UnixListener don't work for "unixgram" and "unixpacket". // UnixAddr represents the address of a Unix domain socket end point. type UnixAddr struct { Name string Net string } // Network returns the address's network name, "unix", "unixgram" or // "unixpacket". func (a *UnixAddr) Network() string { return a.Net } func (a *UnixAddr) String() string { if a == nil { return "<nil>" } return a.Name } func (a *UnixAddr) isWildcard() bool { return a == nil || a.Name == "" } func (a *UnixAddr) opAddr() Addr { if a == nil { return nil } return a } // ResolveUnixAddr returns an address of Unix domain socket end point. // // The network must be a Unix network name. // // See func Dial for a description of the network and address // parameters. func ResolveUnixAddr(network, address string) (*UnixAddr, error) { switch network { case "unix", "unixgram", "unixpacket": return &UnixAddr{Name: address, Net: network}, nil default: return nil, UnknownNetworkError(network) } } // UnixConn is an implementation of the Conn interface for connections // to Unix domain sockets. type UnixConn struct { conn } // SyscallConn returns a raw network connection. // This implements the syscall.Conn interface. func (c *UnixConn) SyscallConn() (syscall.RawConn, error) { if !c.ok() { return nil, syscall.EINVAL } return newRawConn(c.fd) } // CloseRead shuts down the reading side of the Unix domain connection. // Most callers should just use Close. func (c *UnixConn) CloseRead() error { if !c.ok() { return syscall.EINVAL } if err := c.fd.closeRead(); err != nil { return &OpError{Op: "close", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} } return nil } // CloseWrite shuts down the writing side of the Unix domain connection. // Most callers should just use Close. func (c *UnixConn) CloseWrite() error { if !c.ok() { return syscall.EINVAL } if err := c.fd.closeWrite(); err != nil { return &OpError{Op: "close", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} } return nil } // ReadFromUnix acts like ReadFrom but returns a UnixAddr. func (c *UnixConn) ReadFromUnix(b []byte) (int, *UnixAddr, error) { if !c.ok() { return 0, nil, syscall.EINVAL } n, addr, err := c.readFrom(b) if err != nil { err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} } return n, addr, err } // ReadFrom implements the PacketConn ReadFrom method. func (c *UnixConn) ReadFrom(b []byte) (int, Addr, error) { if !c.ok() { return 0, nil, syscall.EINVAL } n, addr, err := c.readFrom(b) if err != nil { err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} } if addr == nil { return n, nil, err } return n, addr, err } // ReadMsgUnix reads a message from c, copying the payload into b and // the associated out-of-band data into oob. It returns the number of // bytes copied into b, the number of bytes copied into oob, the flags // that were set on the message and the source address of the message. // // Note that if len(b) == 0 and len(oob) > 0, this function will still // read (and discard) 1 byte from the connection. func (c *UnixConn) ReadMsgUnix(b, oob []byte) (n, oobn, flags int, addr *UnixAddr, err error) { if !c.ok() { return 0, 0, 0, nil, syscall.EINVAL } n, oobn, flags, addr, err = c.readMsg(b, oob) if err != nil { err = &OpError{Op: "read", Net: c.fd.net, Source: c.fd.laddr, Addr: c.fd.raddr, Err: err} } return } // WriteToUnix acts like WriteTo but takes a UnixAddr. func (c *UnixConn) WriteToUnix(b []byte, addr *UnixAddr) (int, error) { if !c.ok() { return 0, syscall.EINVAL } n, err := c.writeTo(b, addr) if err != nil { err = &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: addr.opAddr(), Err: err} } return n, err } // WriteTo implements the PacketConn WriteTo method. func (c *UnixConn) WriteTo(b []byte, addr Addr) (int, error) { if !c.ok() { return 0, syscall.EINVAL } a, ok := addr.(*UnixAddr) if !ok { return 0, &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: addr, Err: syscall.EINVAL} } n, err := c.writeTo(b, a) if err != nil { err = &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: a.opAddr(), Err: err} } return n, err } // WriteMsgUnix writes a message to addr via c, copying the payload // from b and the associated out-of-band data from oob. It returns the // number of payload and out-of-band bytes written. // // Note that if len(b) == 0 and len(oob) > 0, this function will still // write 1 byte to the connection. func (c *UnixConn) WriteMsgUnix(b, oob []byte, addr *UnixAddr) (n, oobn int, err error) { if !c.ok() { return 0, 0, syscall.EINVAL } n, oobn, err = c.writeMsg(b, oob, addr) if err != nil { err = &OpError{Op: "write", Net: c.fd.net, Source: c.fd.laddr, Addr: addr.opAddr(), Err: err} } return } func newUnixConn(fd *netFD) *UnixConn { return &UnixConn{conn{fd}} } // DialUnix acts like Dial for Unix networks. // // The network must be a Unix network name; see func Dial for details. // // If laddr is non-nil, it is used as the local address for the // connection. func DialUnix(network string, laddr, raddr *UnixAddr) (*UnixConn, error) { switch network { case "unix", "unixgram", "unixpacket": default: return nil, &OpError{Op: "dial", Net: network, Source: laddr.opAddr(), Addr: raddr.opAddr(), Err: UnknownNetworkError(network)} } sd := &sysDialer{network: network, address: raddr.String()} c, err := sd.dialUnix(context.Background(), laddr, raddr) if err != nil { return nil, &OpError{Op: "dial", Net: network, Source: laddr.opAddr(), Addr: raddr.opAddr(), Err: err} } return c, nil } // UnixListener is a Unix domain socket listener. Clients should // typically use variables of type Listener instead of assuming Unix // domain sockets. type UnixListener struct { fd *netFD path string unlink bool unlinkOnce sync.Once } func (ln *UnixListener) ok() bool { return ln != nil && ln.fd != nil } // SyscallConn returns a raw network connection. // This implements the syscall.Conn interface. // // The returned RawConn only supports calling Control. Read and // Write return an error. func (l *UnixListener) SyscallConn() (syscall.RawConn, error) { if !l.ok() { return nil, syscall.EINVAL } return newRawListener(l.fd) } // AcceptUnix accepts the next incoming call and returns the new // connection. func (l *UnixListener) AcceptUnix() (*UnixConn, error) { if !l.ok() { return nil, syscall.EINVAL } c, err := l.accept() if err != nil { return nil, &OpError{Op: "accept", Net: l.fd.net, Source: nil, Addr: l.fd.laddr, Err: err} } return c, nil } // Accept implements the Accept method in the Listener interface. // Returned connections will be of type *UnixConn. func (l *UnixListener) Accept() (Conn, error) { if !l.ok() { return nil, syscall.EINVAL } c, err := l.accept() if err != nil { return nil, &OpError{Op: "accept", Net: l.fd.net, Source: nil, Addr: l.fd.laddr, Err: err} } return c, nil } // Close stops listening on the Unix address. Already accepted // connections are not closed. func (l *UnixListener) Close() error { if !l.ok() { return syscall.EINVAL } if err := l.close(); err != nil { return &OpError{Op: "close", Net: l.fd.net, Source: nil, Addr: l.fd.laddr, Err: err} } return nil } // Addr returns the listener's network address. // The Addr returned is shared by all invocations of Addr, so // do not modify it. func (l *UnixListener) Addr() Addr { return l.fd.laddr } // SetDeadline sets the deadline associated with the listener. // A zero time value disables the deadline. func (l *UnixListener) SetDeadline(t time.Time) error { if !l.ok() { return syscall.EINVAL } if err := l.fd.pfd.SetDeadline(t); err != nil { return &OpError{Op: "set", Net: l.fd.net, Source: nil, Addr: l.fd.laddr, Err: err} } return nil } // File returns a copy of the underlying os.File. // It is the caller's responsibility to close f when finished. // Closing l does not affect f, and closing f does not affect l. // // The returned os.File's file descriptor is different from the // connection's. Attempting to change properties of the original // using this duplicate may or may not have the desired effect. func (l *UnixListener) File() (f *os.File, err error) { if !l.ok() { return nil, syscall.EINVAL } f, err = l.file() if err != nil { err = &OpError{Op: "file", Net: l.fd.net, Source: nil, Addr: l.fd.laddr, Err: err} } return } // ListenUnix acts like Listen for Unix networks. // // The network must be "unix" or "unixpacket". func ListenUnix(network string, laddr *UnixAddr) (*UnixListener, error) { switch network { case "unix", "unixpacket": default: return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: laddr.opAddr(), Err: UnknownNetworkError(network)} } if laddr == nil { return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: laddr.opAddr(), Err: errMissingAddress} } sl := &sysListener{network: network, address: laddr.String()} ln, err := sl.listenUnix(context.Background(), laddr) if err != nil { return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: laddr.opAddr(), Err: err} } return ln, nil } // ListenUnixgram acts like ListenPacket for Unix networks. // // The network must be "unixgram". func ListenUnixgram(network string, laddr *UnixAddr) (*UnixConn, error) { switch network { case "unixgram": default: return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: laddr.opAddr(), Err: UnknownNetworkError(network)} } if laddr == nil { return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: nil, Err: errMissingAddress} } sl := &sysListener{network: network, address: laddr.String()} c, err := sl.listenUnixgram(context.Background(), laddr) if err != nil { return nil, &OpError{Op: "listen", Net: network, Source: nil, Addr: laddr.opAddr(), Err: err} } return c, nil }
Upload File
Create Folder