Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server represents a TCP server capable of accepting connections, and pushing them into the Clients() channel.
Underneath the hood, type `Server` uses a net.Listener (of the TCP-variety) to listen for connections, and maintains a channel for errors, as well as a channel for clients.
func New ¶
New instantiates and returns a new server, bound to the `bind` address given. Semantics for `bind` follow those set forth in the `net` package. Calling `New()` does in-fact create a TCP Listener on that address, and returns an error if the address is non-parsable, or the network is not able to be bound.
Otherwise, a server is returned.
func (*Server) Accept ¶
func (s *Server) Accept()
Accept encapsulates the process of accepting new clients to the server.
In the failing case, if an error is returned from attempting to connect to a socket, then the error will be piped up to the Errs() channel, and the connection request will be ignreod.
In the successful case, the client is written to the internal `clients` channel, which is readable from the Clients() method.
Accept runs within its own goroutine.
func (*Server) Clients ¶
Clients returns a read-only channel of *client.Client, written to when a new connection is obtained into the server.