Documentation ¶
Overview ¶
Package persistent implements "virtual connections", many of which utilize the same underlying TCP link. Each virtual connection has a unique ID and every piece of data sent through the common TCP link is prefixed with a 12 bytes long header consisting of this ID (8 bytes) and the length of the piece of data (4 bytes).
All writes are buffered and the actual network traffic happens only on Flush (which needs to be invoked explicitly) or when the buffer is full. Reads are also buffered and they read byte slices from the channel populated by the link supervising the connection. Close sends a header with data length set to 0. After closing the connection, calling Write or Flush returns an error, but reading is still possible until the underlying channel is depleted.
NOTE: Write() and Flush() are NOT thread safe!
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶
func NewServer(localAddress string, remoteAddresses []string, timeout time.Duration) (network.Server, core.Service, error)
NewServer initializes network setup for the given local address and the set of remote addresses. Returns an object that implements BOTH network.Server and core.Service interfaces. It needs to be started as a service to activate listening for incoming TCP connections.
Types ¶
This section is empty.