Documentation
¶
Index ¶
Constants ¶
View Source
const (
// LF the string of linefeed
LF = "\n"
)
Variables ¶
View Source
var ( // EndIdentity the network communication end identity EndIdentity = []byte("_$#END#$_") // ErrorIdentity the network communication error identity ErrorIdentity = []byte("_$#ERR#$_") // ErrorEndIdentity the network communication end identity with error identity ErrorEndIdentity = append(ErrorIdentity, EndIdentity...) // LFBytes the linefeed bytes LFBytes = []byte(LF) )
View Source
var ( // ServerExecuteError the remote server execute error ServerExecuteError = errors.New("server execute error") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // Connect connect to the server Connect() error // Write write data to the server Write(data []byte) error // ReadAll read all the data of the server ReadAll() (data []byte, err error) // Host return the client host Host() string // Port return the client bind port Port() int // Close close the client connection Close() error // IsClosed is connection closed of the current client IsClosed() bool }
Client a network communication client
type Conn ¶
func (*Conn) Authorized ¶
func (*Conn) MarkAuthorized ¶
func (*Conn) StartAuthCheck ¶
func (conn *Conn) StartAuthCheck()
StartAuthCheck auto check auth state per second, close the connection if unauthorized after one minute
type Server ¶
type Server interface { // Listen listen the specified port to wait client connect Listen() error // Accept accept the client connection Accept(process func(client *Conn, data []byte)) error // ClientCount the client count of the connected ClientCount() int // Send send the data to the client Send([]byte) error // Host return the server host Host() string // Port return the server bind port Port() int // Close close the server Close() error // Auth client sign in Auth(user *auth.HashUser) (bool, auth.Perm) }
Server a network communication server
Click to show internal directories.
Click to hide internal directories.