Documentation ¶
Index ¶
- Variables
- func BufioConn() net.Conn
- func CloseRead(conn net.Conn) error
- func CloseWrite(conn net.Conn) error
- func GetCurrentAddrListString() string
- func GetDefaultGateway() string
- func IsBadFileDescripter(err error) bool
- func IsConnectionRefused(err error) bool
- func IsNetworkIsUnreachable(err error) bool
- func IsNoRouteToHost(err error) bool
- func IsPrivateNetwork(ip net.IP) bool
- func IsResourceBusy(err error) bool
- func IsSocketCloseError(err error) bool
- func IsTimeoutError(err error) bool
- func JoinHostPortInt(host string, port int) string
- func LessDelayDial(network string, address string) (conn net.Conn, err error)
- func LessDelayTcpConn(conn *net.TCPConn) (connOut net.Conn, err error)
- func ListenerConnWrapper(l net.Listener, connWrapper ConnWrapper) net.Listener
- func MustGetCurrentIpList() (ipList []net.IP)
- func MustGetCurrentIpWithPortList(port uint16) (sList []string)
- func MustGetFirstIPByNetDeviceName(devname string) net.IP
- func MustGetHostFromAddr(addr string) string
- func MustGetIpFromAddr(addri net.Addr) (ip net.IP)
- func MustGetLocalAddrFromAddr(addr net.Addr) string
- func MustGetLocalAddrFromListener(listener net.Listener) string
- func MustGetServerAddrString(s Server) string
- func MustGetServerLocalAddrString(s Server) string
- func MustLessDelayListen(network string, address string) net.Listener
- func MustListen(network string, address string) net.Listener
- func MustParseCIDR(s string) *net.IPNet
- func MustServerStart(s Server)
- func MustTcpRandomListen() net.Listener
- func NewDebugConn(conn net.Conn, name string) net.Conn
- func NewDebugConnNoData(conn net.Conn) net.Conn
- func NewFixedAddressDialer(parent Dialer, network string, address string) func() (net.Conn, error)
- func NewFixedDialerV2(parent Dialer, network string, address string) func(network, address string) (net.Conn, error)
- func NewRwcOverConn(rwc io.ReadWriteCloser, conn net.Conn) net.Conn
- func NewSizeDebugConn(conn net.Conn, name string) net.Conn
- func NewStringDebugConn(conn net.Conn, name string) net.Conn
- func NewTimeoutDialer(timeout time.Duration) func(network, addr string) (net.Conn, error)
- func PortFromAddrString(addr string) (int, error)
- func PortFromNetAddr(addr net.Addr) (int, error)
- func RunTCPServerListenAddr(listenAddr string, handle ConnHandlerFunc) (closer func() error)
- func RunTCPServerV2(Listener net.Listener, handle ConnHandlerFunc) (closer func() error)
- func RwcConn(rwc io.ReadWriteCloser) net.Conn
- func SetDnsServerAddr(ip string)
- func SizeString(byteNum int64) string
- func SizeStringWithPadding(byteNum int64) string
- func SpeedString(byteNum int, dur time.Duration) string
- func SpeedStringWithFloat(bytePerSecond float64) string
- func TimeoutConn(conn net.Conn, timeout time.Duration) net.Conn
- type ConnHandler
- type ConnHandlerFunc
- type ConnServer
- type ConnWrapper
- type DeviceAddr
- type Dialer
- type DirectDialer
- type DirectDialerFunc
- type FixedAddressDialer
- type FuncServer
- type GetUnderlyingConner
- type RwcDialer
- type RwcDialerFunc
- type RwcOverConn
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrClosing = errors.New("use of closed network connection")
View Source
var FakeAddr = fakeAddr{}
View Source
var ProtocolNotSupportPortError = errors.New("Protocol Not Support Port")
Functions ¶
func CloseWrite ¶
func GetDefaultGateway ¶
func GetDefaultGateway() string
func IsBadFileDescripter ¶
func IsConnectionRefused ¶
icmp 报告服务器不存在,通常是服务器掉进程了. 出现位置 udp write
func IsNetworkIsUnreachable ¶
当前设备没有可用的网络设备,在网络切换时会出现 出现位置 udp read, udp write,udp dial
func IsPrivateNetwork ¶
func IsSocketCloseError ¶
是否是因为socket没有关闭,或者socket根本没有连接而导致的错误,或者被reset (表示这个连接应该被马上关闭) 这个可以用来在监听请求的时候,检测到服务器关闭事件.
func IsTimeoutError ¶
在网络请求额时候,使用conn.SetDeadLine(xxx) 设置超时时间后,请求确实超过超时时间的报错.
func JoinHostPortInt ¶
func ListenerConnWrapper ¶
func ListenerConnWrapper(l net.Listener, connWrapper ConnWrapper) net.Listener
func MustGetFirstIPByNetDeviceName ¶
返回nil表示没找到这个设备,或者这个设备上面没有ip
func MustGetHostFromAddr ¶
func MustGetLocalAddrFromAddr ¶
从一个net.Listener里面读取需要Dial的地址(测试用的比较多)
func MustGetLocalAddrFromListener ¶
从一个net.Listener里面读取需要Dial的地址(测试用的比较多)
func MustGetServerAddrString ¶
func MustParseCIDR ¶
func MustServerStart ¶
func MustServerStart(s Server)
func MustTcpRandomListen ¶
func NewFixedAddressDialer ¶
func NewFixedDialerV2 ¶
func NewRwcOverConn ¶
func NewTimeoutDialer ¶
拨号的时候有一个timeout,每次读和写的时候也有一个timeout
func PortFromAddrString ¶
func RunTCPServerListenAddr ¶
func RunTCPServerListenAddr(listenAddr string, handle ConnHandlerFunc) (closer func() error)
func RunTCPServerV2 ¶
func RunTCPServerV2(Listener net.Listener, handle ConnHandlerFunc) (closer func() error)
func SetDnsServerAddr ¶
func SetDnsServerAddr(ip string)
func SizeString ¶
func SizeStringWithPadding ¶
在开头加padding,尝试使长度一致,如果数据超级大有可能会坏掉
func SpeedStringWithFloat ¶
Types ¶
type ConnHandler ¶
type ConnHandlerFunc ¶
func (ConnHandlerFunc) ConnHandle ¶
func (f ConnHandlerFunc) ConnHandle(conn net.Conn)
type ConnServer ¶
type ConnServer struct { Listener net.Listener Handler ConnHandler Closer io.Closer }
func NewTCPServer ¶
func NewTCPServer(listenAddr string, hander ConnHandler, closer io.Closer) (s *ConnServer, err error)
这一步会开始监听
func (*ConnServer) Close ¶
func (server *ConnServer) Close() (err error)
type DeviceAddr ¶
type DeviceAddr struct { IP net.IP //地址上面的ip IPNet *net.IPNet //地址上面的子网 DevString string //设备名称 eth0 什么的 }
一个网络设备上面的地址
type Dialer ¶
func NewDebugDialerNoData ¶
type DirectDialer ¶
type DirectDialerFunc ¶
type FixedAddressDialer ¶
type FuncServer ¶
type FuncServer struct { StartFunc func() error CloseFunc func() error AddrFunc func() (net.Addr, error) ExistAddr net.Addr }
func (*FuncServer) Addr ¶
func (s *FuncServer) Addr() (net.Addr, error)
监听地址,如果可能请返回net库里面有的Addr,如果还没有开始监听会panic
func (*FuncServer) Start ¶
func (s *FuncServer) Start() error
type GetUnderlyingConner ¶
type RwcDialer ¶
type RwcDialer interface {
RwcDial(addr string) (rwc io.ReadWriteCloser, err error)
}
type RwcDialerFunc ¶
type RwcDialerFunc func(addr string) (rwc io.ReadWriteCloser, err error)
func (RwcDialerFunc) RwcDial ¶
func (f RwcDialerFunc) RwcDial(addr string) (rwc io.ReadWriteCloser, err error)
type RwcOverConn ¶
func (*RwcOverConn) Close ¶
func (c *RwcOverConn) Close() (err error)
func (*RwcOverConn) GetUnderlyingConn ¶
func (c *RwcOverConn) GetUnderlyingConn() net.Conn
Source Files ¶
Click to show internal directories.
Click to hide internal directories.