Documentation ¶
Overview ¶
A simple implementation of ETSN: https://raw.github.com/250bpm/nanomsg/master/rfc/etsn-01.txt
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Dial ¶
Dial connects to the specified ETSN server and requests protocol proto.
nett must be one of "tcp", "tcp4", "tcp6".
laddr is standard Go networking address as used in the net package. If the laddr string ends in ":", the default port, 5908, is appended.
If the server server does not speak the protocol proto, an error will be returned; otherwise a TCP connection is returned ready to use.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server encapsulates the state of an ETSN server.
func New ¶
New returns a new Server.
logger is called whenever there's an error establishing a connection within Listen. Note that the error may be nil. If logger is nil, a no op logger is used. The logger may be called by multiple goroutines. Errors returned from handlers are passed to logger.
func (*Server) Help ¶
Help is a local version of the TCPMUX HELP protocol. It returns a list of all the protocols the server implements. It is not exposed by the server, but can be made to do so trivially, if desired: (error handling elided for brevity)
server.Register("HELP", func(c *net.TCPConn) { w := bufio.NewWriter(c) for _, p := range server.Help() { w.WriteString(p) w.WriteByte('\n') } w.Flush() c.Close() })
func (*Server) Listen ¶
Listen starts an ETSN server on port 5908.
When connections are made they are dispatched, based on the client's requested protocol identifier, to any handler registered via Register, otherwise the request is dropped.
If a logger was set with SetListenLogger, all errors during the ETSN handshake will be passed to it, there will be at most one error per goroutine.
nett must be one of "tcp", "tcp4", "tcp6".
laddr is standard Go networking address as used in the net package. If the laddr string ends in ":", the default port, 5908, is appended.
func (*Server) ProtocolMissing ¶
ProtocolMissing is called when no protocol is found. The first argument is the name of the unknown protocol, otherwise it behaves exactly like a regular handler. If no ProtocolMissing handler is set, or this is called with nil, requests will be closed and ignored.
func (*Server) Register ¶
Register registers a handler function for the protocol named proto.
If there was already a protocol registered with identifier proto, handler will be used for any future connections. All existing connections of proto will remain with the previous handler until the connections are closed.
func (*Server) Unregister ¶
Unregister removes any handler associated with the identifier proto, if present.
No existing connection will be effected.
Directories ¶
Path | Synopsis |
---|---|
Create an ETSN server that sends its connections to other procs over unix domain sockets.
|
Create an ETSN server that sends its connections to other procs over unix domain sockets. |
etsnunix implements an interface similar to etsn, but for listening for connections on a unix socket provided by the etsnsrv command.
|
etsnunix implements an interface similar to etsn, but for listening for connections on a unix socket provided by the etsnsrv command. |