type AddrError

func (e *AddrError) Error() string

func (e *AddrError) Temporary() bool

func (e *AddrError) Timeout() bool

type Buffers

typeBuffers [][]byte

func (v *Buffers) Read(p []byte) (n int, err error)

func (v *Buffers) WriteTo(w io.Writer) (n int64, err error)

type Conn

typeConninterface {
// Read reads data from the connection.// Read can be made to time out and return an Error with Timeout() == true// after a fixed time limit; see SetDeadline and SetReadDeadline.Read(b []byte) (n int, err error)
// Write writes data to the connection.// Write can be made to time out and return an Error with Timeout() == true// after a fixed time limit; see SetDeadline and SetWriteDeadline.Write(b []byte) (n int, err error)
// Close closes the connection.// Any blocked Read or Write operations will be unblocked and return errors.Close() error
// LocalAddr returns the local network address.LocalAddr() Addr
// RemoteAddr returns the remote network address.RemoteAddr() Addr
// SetDeadline sets the read and write deadlines associated// with the connection. It is equivalent to calling both// SetReadDeadline and SetWriteDeadline.//// A deadline is an absolute time after which I/O operations// fail with a timeout (see type Error) instead of// blocking. The deadline applies to all future and pending// I/O, not just the immediately following call to Read or// Write. After a deadline has been exceeded, the connection// can be refreshed by setting a deadline in the future.//// An idle timeout can be implemented by repeatedly extending// the deadline after successful Read or Write calls.//// A zero value for t means I/O operations will not time out.SetDeadline(t time.Time) error
// SetReadDeadline sets the deadline for future Read calls// and any currently-blocked Read call.// A zero value for t means Read will not time out.SetReadDeadline(t time.Time) error
// SetWriteDeadline sets the deadline for future Write calls// and any currently-blocked Write call.// Even if write times out, it may return n > 0, indicating that// some of the data was successfully written.// A zero value for t means Write will not time out.SetWriteDeadline(t time.Time) error
}

func FileConn(f *os.File) (c Conn, err error)

FileConn returns a copy of the network connection corresponding to the open file f. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.

type DNSConfigError

func (e *DNSConfigError) Error() string

func (e *DNSConfigError) Temporary() bool

func (e *DNSConfigError) Timeout() bool

type DNSError

func (e *DNSError) Error() string

func (e *DNSError) Temporary() bool

func (e *DNSError) Timeout() bool

type Dialer

typeDialerstruct {
// Timeout is the maximum amount of time a dial will wait for// a connect to complete. If Deadline is also set, it may fail// earlier.//// The default is no timeout.//// When using TCP and dialing a host name with multiple IP// addresses, the timeout may be divided between them.//// With or without a timeout, the operating system may impose// its own earlier timeout. For instance, TCP timeouts are// often around 3 minutes.
Timeout time.Duration
// Deadline is the absolute point in time after which dials// will fail. If Timeout is set, it may fail earlier.// Zero means no deadline, or dependent on the operating system// as with the Timeout option.
Deadline time.Time
// LocalAddr is the local address to use when dialing an// address. The address must be of a compatible type for the// network being dialed.// If nil, a local address is automatically chosen.
LocalAddr Addr
// DualStack enables RFC 6555-compliant "Happy Eyeballs"// dialing when the network is "tcp" and the host in the// address parameter resolves to both IPv4 and IPv6 addresses.// This allows a client to tolerate networks where one address// family is silently broken.
DualStack bool
// FallbackDelay specifies the length of time to wait before// spawning a fallback connection, when DualStack is enabled.// If zero, a default delay of 300ms is used.
FallbackDelay time.Duration
// KeepAlive specifies the keep-alive period for an active// network connection.// If zero, keep-alives are not enabled. Network protocols// that do not support keep-alives ignore this field.
KeepAlive time.Duration
// Resolver optionally specifies an alternate resolver to use.
Resolver *Resolver
// Cancel is an optional channel whose closure indicates that// the dial should be canceled. Not all types of dials support// cancelation.//// Deprecated: Use DialContext instead.
Cancel <-chanstruct{}
}

func (a *TCPAddr) String() string

type TCPConn

func DialTCP(network string, laddr, raddr *TCPAddr) (*TCPConn, error)

If laddr is nil, a local address is automatically chosen. If the IP field of raddr is nil or an unspecified IP address, the local system is assumed.

func (c *TCPConn) Close() error

Close closes the connection.

func (c *TCPConn) CloseRead() error

CloseRead shuts down the reading side of the TCP connection. Most callers should just use Close.

func (c *TCPConn) CloseWrite() error

CloseWrite shuts down the writing side of the TCP connection. Most callers should just use Close.

func (c *TCPConn) File() (f *os.File, err error)

File sets the underlying os.File to blocking mode and returns a copy. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.

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 (c *TCPConn) LocalAddr() Addr

LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.

func (c *TCPConn) Read(b []byte) (int, error)

Read implements the Conn Read method.

func (c *TCPConn) ReadFrom(r io.Reader) (int64, error)

ReadFrom implements the io.ReaderFrom ReadFrom method.

func (c *TCPConn) RemoteAddr() Addr

RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.

func (c *TCPConn) SetDeadline(t time.Time) error

SetDeadline implements the Conn SetDeadline method.

func (c *TCPConn) SetKeepAlive(keepalive bool) error

SetKeepAlive sets whether the operating system should send keepalive messages on the connection.

func (c *TCPConn) SetKeepAlivePeriod(d time.Duration) error

SetKeepAlivePeriod sets period between keep alives.

func (c *TCPConn) SetLinger(sec int) error

SetLinger sets the behavior of Close on a connection which still has data waiting to be sent or to be acknowledged.

If sec < 0 (the default), the operating system finishes sending the data in the background.

If sec == 0, the operating system discards any unsent or unacknowledged data.

If sec > 0, the data is sent in the background as with sec < 0. On some operating systems after sec seconds have elapsed any remaining unsent data may be discarded.** func (c *TCPConn) SetNoDelay(noDelay bool) error
SetNoDelay controls whether the operating system should delay packet transmission in hopes of sending fewer packets (Nagle's algorithm). The default is true (no delay), meaning that data is sent as soon as possible after a Write.

func (c *TCPConn) SetReadBuffer(bytes int) error

SetReadBuffer sets the size of the operating system's receive buffer associated with the connection.

func (c *TCPConn) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (c *TCPConn) SetWriteBuffer(bytes int) error

SetWriteBuffer sets the size of the operating system's transmit buffer associated with the connection.

func (c *TCPConn) SyscallConn() (syscall.RawConn, error)

func (c *TCPConn) Write(b []byte) (int, error)

type TCPListener

func ListenTCP(network string, laddr *TCPAddr) (*TCPListener, error)

ListenTCP acts like Listen for TCP networks.

The network must be a TCP network name; see func Dial for details.

If the IP field of laddr is nil or an unspecified IP address, ListenTCP listens on all available unicast and anycast IP addresses of the local system. If the Port field of laddr is 0, a port number is automatically chosen.

func (l *TCPListener) Accept() (Conn, error)

Accept implements the Accept method in the Listener interface; it waits for the next call and returns a generic Conn.

func (l *TCPListener) AcceptTCP() (*TCPConn, error)

AcceptTCP accepts the next incoming call and returns the new connection.

func (l *TCPListener) Addr() Addr

Addr returns the listener's network address, a *TCPAddr. The Addr returned is shared by all invocations of Addr, so do not modify it.

func (l *TCPListener) Close() error

Close stops listening on the TCP address. Already Accepted connections are not closed.

func (l *TCPListener) File() (f *os.File, err error)

File returns a copy of the underlying os.File, set to blocking mode. 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 *TCPListener) SetDeadline(t time.Time) error

SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.