Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompositeBuffer ¶
type CompositeBuffer = bytebuf.CompositeBuffer
type Conn ¶
type Conn interface {
// LocalAddr is the connection's local socket address.
LocalAddr() net.Addr
// RemoteAddr is the connection's remote address.
RemoteAddr() net.Addr
// Context returns a user-defined context, it's not concurrency-safe.
Context() interface{}
// SetContext sets a user-defined context, it's not concurrency-safe.
SetContext(ctx interface{})
// 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.
SetLinger(secs int) 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.
SetNoDelay(nodelay bool) error
// SetKeepAlive sets whether the operating system should send
// keep-alive messages on the connection.
SetKeepAlive(keepalive bool) error
// SetKeepAlivePeriod tells operating system to send keep-alive messages on the connection
// and sets period between TCP keep-alive probes.
SetKeepAlivePeriod(secs int) error
// SetReadBuffer sets the size of the operating system's
// receive buffer associated with the connection.
SetReadBuffer(size int) error
// SetWriteBuffer sets the size of the operating system's
// transmit buffer associated with the connection.
SetWriteBuffer(size int) error
// SetDeadline sets deadline for both read and write.
// If it is time.Zero, SetDeadline will clear the deadlines.
SetDeadline(t time.Time) error
// SetReadDeadline sets the deadline for future Read calls.
// When the user doesn't update the deadline and the deadline exceeds,
// the connection will be closed.
// If it is time.Zero, SetReadDeadline will clear the deadline.
SetReadDeadline(t time.Time) error
// SetWriteDeadline sets the deadline for future data writing.
// If it is time.Zero, SetReadDeadline will clear the deadline.
SetWriteDeadline(t time.Time) error
// Peek returns the next len(b) bytes without advancing the inbound buffer.
// it's not concurrency-safe.
Peek(b []byte) []byte
// Discard advances the inbound buffer with next n bytes, returning the number of bytes discarded.
// it's not concurrency-safe.
Discard(n int) (int, error)
// InboundBuffered returns a inbound buffer data length.
// it's not concurrency-safe.
InboundBuffered() int
// OutboundBuffered returns a outbound buffer data length.
OutboundBuffered() int
// WriterTo
// it's not concurrency-safe.
// Notice: non-blocking interface, should not be used as you use std.
io.WriterTo
// ReadWriteCloser
// Read() it's not concurrency-safe.
// Notice: non-blocking interface, should not be used as you use std.
io.ReadWriteCloser
// ByteWriter
// Notice: non-blocking interface, should not be used as you use std.
io.ByteWriter
// StringWriter
// Notice: non-blocking interface, should not be used as you use std.
io.StringWriter
// Writev "writev"-like batch write optimization.
// Notice: non-blocking interface, should not be used as you use std.
Writev(vec [][]byte) (int, error)
// Flush writes any buffered data to the underlying connection.
// Notice: non-blocking interface, should not be used as you use std.
Flush() error
// CloseWith close the connection with error.
CloseWith(err error) error
}
Conn is an interface of underlying connection.
type Events ¶
type Events struct {
// Pollers is set up to start the given number of event-loop goroutine.
// The default value is runtime.NumCPU().
Pollers int
// Addrs is the listening addr list for a server.
Addrs []string
// ReusePort indicates whether to set up the SO_REUSEPORT socket option.
// The default value is false.
ReusePort bool
// LockOSThread is used to determine whether each I/O event-loop is associated to an OS thread.
// The default value is false.
LockOSThread bool
// MaxBufferSize is the maximum number of bytes that can be read from the remote when the readable event comes.
// The default value is 4KB.
MaxBufferSize int
// WriteBufferedThreshold enabled when value is greater than 0, writes will go into the outbound buffer instead of attempting to send them out immediately,
// unless the outbound buffer reaches the threshold or the flush function is manually called.
//
// If you have multiple Write call requirements, opening it will improve write performance because it reduces the number of system calls by merging multiple write operations to improve performance.
// The default value is 0.
WriteBufferedThreshold int
// WriteTimeout closes a FullDuplex connection that remains blocked on
// socket writes for this duration. Zero disables the slow-writer timeout.
WriteTimeout time.Duration
// FullDuplex keeps read events registered while the outbound queue is below
// its bounded watermark, which improves throughput in most cases. If a peer
// deliberately reads slowly, the loop temporarily pauses reads at the
// watermark to prevent unbounded outbound memory growth.
// Turning this option off will change the event registration policy, readable events are unregistered if there is currently data waiting to be sent in the outbound buffer.
// Readable events are re-registered after the send buffer has been sent. In this case, network reads and writes will degenerate into half-duplex mode, ensuring that server memory is not exhausted.
// The default value is false.
FullDuplex bool
// OnOpen fires when a new connection has been opened.
OnOpen func(c Conn)
// OnData fires when a socket receives data from the remote.
OnData func(c Conn) error
// OnClose fires when a connection has been closed.
OnClose func(c Conn, err error)
// OnInbound when any bytes read by a socket, it triggers the inbound event.
OnInbound func(c Conn, readBytes int)
// OnOutbound when any bytes write to a socket, it triggers the outbound event.
OnOutbound func(c Conn, writeBytes int)
// OnStart it triggers on the server initialized.
OnStart func(ev *Events)
// OnStop it triggers on the server closed.
OnStop func(ev *Events)
// contains filtered or unexported fields
}
func (*Events) Dial ¶
Dial connects to the address on the named network. The value data is stored as connection user data and does not control the dial; use DialContext for cancellation or deadlines.
Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and "unixpacket".
Examples:
Dial("tcp://golang.org:http")
Dial("tcp://192.0.2.1:http")
Dial("tcp://198.51.100.1:80")
Dial("udp://[2001:db8::1]:domain")
Dial("udp://[fe80::1%lo0]:53")
Dial("tcp://:80")
Dial("unix:///path/your/unix.sock")
func (*Events) DialContext ¶ added in v1.0.1
DialContext connects to addr using ctx for cancellation and deadlines. The value data is stored as the connection's user data.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
module
|
|
|
internal
|
|
|
Package uws provides an asynchronous WebSocket server built on UIO.
|
Package uws provides an asynchronous WebSocket server built on UIO. |
|
autobahn/server
command
|
|
|
examples/echo
command
|
|
|
internal/frame
Package frame implements the wire-level WebSocket frame codec.
|
Package frame implements the wire-level WebSocket frame codec. |