Documentation ¶
Index ¶
- Variables
- func WriteStatus(w io.Writer)
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) OnError(f func(error))
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteBufferLen(len int)
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) Write(b []byte) (n int, err error)
- func (c *Conn) WriteBufferLen() int
- type FirewallCallback
- type NewSocketOpt
- type Option
- type Socket
- func (s *Socket) Accept() (net.Conn, error)
- func (s *Socket) Addr() net.Addr
- func (s *Socket) Close() error
- func (s *Socket) Dial(addr string) (net.Conn, error)
- func (s *Socket) DialContext(ctx context.Context, network, addr string) (_ net.Conn, err error)
- func (s *Socket) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)
- func (s *Socket) LocalAddr() net.Addr
- func (s *Socket) ReadBufferLen() int
- func (s *Socket) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (s *Socket) SetDeadline(t time.Time) error
- func (s *Socket) SetFirewallCallback(f FirewallCallback)
- func (s *Socket) SetOption(opt Option, val int) int
- func (s *Socket) SetReadDeadline(t time.Time) error
- func (s *Socket) SetSyncFirewallCallback(f FirewallCallback)
- func (s *Socket) SetWriteBufferLen(len int)
- func (s *Socket) SetWriteDeadline(t time.Time) error
- func (s *Socket) WriteBufferLen() int
- func (s *Socket) WriteTo(b []byte, addr net.Addr) (int, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrConnClosed = errors.New("closed")
)
var Logger = log.Default.WithContextText("go-libutp")
The default Socket Logger. Override per Socket by using WithLogger with NewSocket.
Functions ¶
func WriteStatus ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) RemoteAddr ¶
func (*Conn) SetWriteBufferLen ¶
func (*Conn) WriteBufferLen ¶
type FirewallCallback ¶
A firewall callback returns true if an incoming connection request should be ignored. This is better than just accepting and closing, as it means no acknowledgement packet is sent.
type NewSocketOpt ¶ added in v1.2.0
type NewSocketOpt func(s *Socket)
func WithLogger ¶ added in v1.2.0
func WithLogger(l log.Logger) NewSocketOpt
type Option ¶
const ( LogNormal Option = C.UTP_LOG_NORMAL LogMtu Option = C.UTP_LOG_MTU LogDebug Option = C.UTP_LOG_DEBUG SendBuffer Option = C.UTP_SNDBUF RecvBuffer Option = C.UTP_RCVBUF TargetDelay Option = C.UTP_TARGET_DELAY TimedOut = C.UTP_ETIMEDOUT )
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
func (*Socket) DialContext ¶
Passing an empty network will use the network of the Socket's listener.
func (*Socket) DialTimeout ¶
func (*Socket) ReadBufferLen ¶
func (*Socket) SetFirewallCallback ¶
func (s *Socket) SetFirewallCallback(f FirewallCallback)
The callback is used before each packet is processed by libutp without the this package's mutex being held. libutp may not actually need the result as the packet might not be a connection attempt. If the callback function is expensive, it may be worth setting a synchronous callback using SetSyncFirewallCallback.
func (*Socket) SetSyncFirewallCallback ¶ added in v1.1.0
func (s *Socket) SetSyncFirewallCallback(f FirewallCallback)
SetSyncFirewallCallback sets a synchronous firewall callback. It's only called as needed by libutp. It is called with the package-wide mutex held. Any locks acquired by the callback should not also be held by code that might use this package.