Documentation
¶
Index ¶
- Constants
- func Connect(proto string, host string, port string, timeout time.Duration, bufferSize int, ...) error
- func Start(proto string, host string, port string, bufferSize int, KeepAlive int, ...)
- type Client
- type ClosedHandler
- type ConnectedHandler
- type DataHandler
- type ErrorHandler
- type Handlers
- type Option
Constants ¶
View Source
const ( // WAITING waiting for connecting WAITING uint = iota // CONNECTING connecting the host CONNECTING // CONNECTED the socket is connected CONNECTED // CLOSED the socket is closed CLOSED )
View Source
const ( // MREAD socket read error ( the local peer closed ) MREAD uint = iota // MBREAK the remote peer closed MBREAK // MCLOSE user send the CLOSE signal MCLOSE )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
Status uint
Conn net.Conn
Option Option
Handlers Handlers
Attempts int
AttemptAfter time.Duration
AttemptTimes int
}
Client the socket client
type Handlers ¶
type Handlers struct {
Data DataHandler
Error ErrorHandler
Closed ClosedHandler
Connected ConnectedHandler
}
Handlers the socket hanlders
type Option ¶
type Option struct {
Protocol string `json:"protocol,omitempty"` // TCP/UDP
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"` // timeout (seconds)
BufferSize int `json:"buffer,omitempty"` // bufferSize
KeepAlive time.Duration `json:"keep,omitempty"` // -1 not keep alive, 0 keep alive always, keep alive n seconds.
AttemptAfter time.Duration `json:"attempt_after,omitempty"` // Attempt attempt_after
Attempts int `json:"attempts,omitempty"` // max times try to reconnect server when connection break (client mode only)
}
Option the socket option
Click to show internal directories.
Click to hide internal directories.