Documentation ¶
Index ¶
- Constants
- Variables
- func BulkFile(dir, affix string, data []byte) (fn string, first bool, cont []byte, end bool)
- func Client(logFunc FuncLog, connFunc FuncConn, network, rmtAddr string, ...) (conn net.Conn, err error)
- func Connected1Peer(logFunc FuncLog, connFunc FuncConn, conn net.Conn, addrReq [2]string)
- func ConnectedUDP(logFunc FuncLog, chn [2]chan RoutCommStruc, conn *net.UDPConn)
- func CurrTime() string
- func DefLanPrt() (ret int)
- func Deinit4Tests()
- func GetAvailFileName(fn, addr string) (string, bool)
- func I18nInit()
- func I18nLoad(lang string) (string, error)
- func Init4Tests(t *testing.T)
- func InitFlags4Tests()
- func IsDataFile(data []byte) (isData, isEnd bool)
- func ListSystemFonts(exts []string) []string
- func ListenIP(network, address string) (*net.IPConn, error)
- func ListenTCP(logFunc FuncLog, connFunc FuncConn, network, address string, ...) (net.Listener, error)
- func ListenUDP(network, address string) (*net.UDPConn, error)
- func ListenUnixgram(network, address string) (*net.UnixConn, error)
- func MatchFontFromCurrLanguageCfg()
- func MatchSystemFontsFromIndex(indx int) string
- func MatchSystemFontsFromPath(str string) int
- func MdnsClient(localName string, chnAddr chan netip.Addr, chnStp chan struct{}, ...)
- func MdnsServer(localName string, chnStp chan struct{}, chnErr chan error) (server *mdns.Conn, err error)
- func ReadCfg(cfg string, fallbackLang string) error
- func ReaderCfg(rdr io.ReadCloser, fallbackLang string) error
- func RunFlow(flow FlowStruc) bool
- func SetLog(fil string, wr io.Writer) (err error)
- func SndFile(fn string, rdr io.ReadCloser, proc func([]byte) error) error
- func SplitFile(fn string, rdr io.ReadCloser, proc func([]byte) error) error
- func Sz41stChunk(fnI string) (int, string)
- func TryOnlyChunk(fnI string, rdr io.ReadCloser) (string, []byte, error)
- func WriteCfg() error
- func WriterCfg(wrt io.WriteCloser) error
- type FlowConnStruc
- func (conn *FlowConnStruc) Connected(logFunc FuncLog, connFunc FuncConn, connTCP net.Conn, addr [2]string)
- func (conn *FlowConnStruc) LockLog(nm string, lck bool)
- func (conn *FlowConnStruc) ParsePeer(flow FlowStruc)
- func (conn *FlowConnStruc) Run(flow *FlowStruc)
- func (conn *FlowConnStruc) RunCln(flow FlowStruc)
- func (conn *FlowConnStruc) RunSvr(flow FlowStruc)
- func (conn FlowConnStruc) Step1(flow *FlowStruc, step *FlowStepStruc)
- func (conn FlowConnStruc) StepAll(flow *FlowStruc, steps []FlowStepStruc)
- func (conn *FlowConnStruc) Wait4(flow FlowStruc) (ret string)
- type FlowStepStruc
- type FlowStruc
- type Fonts
- type FuncConn
- type FuncLog
- type HTTPSvr
- func (svr *HTTPSvr) FS(relativePath, rootPath string, fs http.FileSystem)
- func (svr *HTTPSvr) GET(relativePath string, fun HTTPSvrProcFunc)
- func (svr *HTTPSvr) POST(relativePath string, fun HTTPSvrProcFunc)
- func (svr *HTTPSvr) Serve(lst net.Listener) chan error
- func (svr *HTTPSvr) Shutdown(timeout time.Duration) error
- type HTTPSvrBody
- type HTTPSvrProcFunc
- type RoutCommStruc
- type SvrTCP
Constants ¶
const ( // EzcName app name, such as for log file EzcName = "EZComm" // EzcURL URL of homepage EzcURL = "https://gitlab.com/bon-ami/ezcomm" // LogExt log file extension LogExt = ".log" // Localhost default peer address Localhost = "localhost" // use "" instead to listen on all interfaces // DefBrdAdr address for broadcast in lan discovery DefBrdAdr = "255.255.255.255" // broadcast addr // StrUDP is UDP protocol. otherwise, udp4, udp6, etc. StrUDP = "udp" // StrTCP is TCP protocol. otherwise, tcp4, tcp6, etc. StrTCP = "tcp" // DefAntFldLmt default anti-flood limit to tolerate a peer DefAntFldLmt = 10 // DefAntFldPrd default anti-flood period to block a peer DefAntFldPrd = 60 )
const ( // FileIDMax max file ID FileIDMax = 255 // FileIDMin min file ID FileIDMin = 1 // FileHdr1stLen min file header length FileHdr1stLen = 6 // FileHdrRstLen min file header length FileHdrRstLen = 6 )
const ( // FlowActRcv action receive FlowActRcv = "receive" // FlowActSnd action send FlowActSnd = "send" // FlowVarSign sign of vars FlowVarSign = "%" // FlowVarSep separator for vars FlowVarSep = "." // FlowVarLst var listen FlowVarLst = "listen" // FlowVarLcl var local FlowVarLcl = "local" // FlowVarPee var peer FlowVarPee = "peer" // FlowVarFil var file FlowVarFil = "file" // FlowVarScr var script FlowVarScr = "script" // FlowRcvLen is the size of receive buffer FlowRcvLen = 1024 * 1024 // must > FileHdr1stLen+len(EzcName) // FlowComLen is the size of the queue between EZComm and UI FlowComLen = 99 // FlowFilLen is the size of send buffer for files FlowFilLen = 1024 * 1024 )
const ( // FlowParseValSimple is a string without <FlowVarSign> FlowParseValSimple = iota // FlowParseValSign is for <FlowVarSign><string><FlowVarSign> FlowParseValSign // FlowParseValVar is for <FlowVarSign><xml tag name of FlowConnStruc/FlowStepStruc><FlowVarSign><string><FlowVarSign> FlowParseValVar )
const ( // FlowChnLst is not used by EZ Comm FlowChnLst = iota // FlowChnEnd is to end a connection/server, to EZ Comm, // or, a connection ends, from EZ Comm FlowChnEnd // FlowChnDie is not used by EZ Comm FlowChnDie // FlowChnSnd is to send sth, to EZ Comm // or, sth is sent, from EZ Comm FlowChnSnd // FlowChnSndFil is FlowChnSnd for files FlowChnSndFil // FlowChnSnt is not used by EZ Comm FlowChnSnt // FlowChnRcv is sth received, from EZ Comm FlowChnRcv // FlowChnRcvFil is FlowChnRcv for files, not used by EZ Comm. For flow only, currently FlowChnRcvFil )
const ( // HTTPSvrHTMLContentType ContentType of HTML for HTTPSvr HTTPSvrHTMLContentType = "text/html; charset=utf-8" // HTTPSvrBodyString string as body for HTTPSvr HTTPSvrBodyString = iota // HTTPSvrBodyHTML html as body for HTTPSvr // this is same as HTTPSvrBodyString, // in addition, it sets ContentType to HTTPSvrHTMLContentType HTTPSvrBodyHTML // HTTPSvrBodyJSON json as body for HTTPSvr HTTPSvrBodyJSON )
const ( // TstHalo beginning string TstHalo = "bonjour" // TstBye ending string TstBye = "ciao" )
Variables ¶
var ( // Ver = verison Ver string // Bld = build, a number or date Bld string // Vendor & AdditionalCfgPath are to locate config file {EzcName}.xml under // {system-app-local-dir}/{Vendor}/{EzcName}/{AdditionalCfgPath} // it may vary among GUI's Vendor string // AdditionalCfgPath is to locate config file. Refer to Vendor AdditionalCfgPath string )
var ( // StringTran maps StringIndx to resource StringTran map[string]string // StringIndx is key to StringTran StringIndx = [...]string{ "StrURLReadMe", "StrEzcName", "StrEzpName", "StrInt", "StrFil", "StrDir", "StrFilO", "StrCfg", "StrLcl", "StrRmt", "StrLst", "StrLstFl", "StrDis", "StrStp", "StrCon", "StrAdr", "StrPrt", "StrRec", "StrCnt", "StrSnd", "StrTo", "StrFrm", "StrFlw", "StrStb", "StrAll", "StrLogExp", "StrLang", "StrVbs", "StrHgh", "StrMdm", "StrLow", "StrNon", "StrFnt", "StrFnt4Lang", "StrFnt4LangBuiltin", "StrReboot4Change", "StrFntRch", "StrVer", "StrHlp", "StrV", "StrVV", "StrVVV", "StrLogFn", "StrCfgFn", "StrFlowFnInf", "StrFlowOpenErr", "StrFlowOpenNot", "StrFlowRunning", "StrFlowRunNot", "StrOK", "StrNG", "StrFlowFinAs", "StrCut", "StrCpy", "StrPst", "StrCpyAll", "StrClr", "StrListeningOn", "StrConnFail", "StrConnected", "StrDisconnected", "StrNotInRec", "StrSvrIdle", "StrClntLft", "StrNoPeer4", "StrDisconnecting", "StrStopLstn", "StrFl2Rcv", "StrGotFromSw", "StrGotFrom", "StrUnknownDsc", "StrFl2Snd", "StrSw", "StrSnt2", "StrInfLog", "StrAntiFld", "StrLmt", "StrPrd", "StrTooLarge2Rcv", "StrFileAwareness", "StrFileSave", "StrInfLan", "StrPokePeer", "StrDiscoverFail", "StrAlert", "StrNoPerm", "StrRcvFil", "StrDownloads", "StrExp", "StrRmAll", "StrDel", "StrCopied", "StrHeader", "StrValue", "StrSE2Del", "StrTxt2ShareBtCS", "StrLanHint", } )
var ( // TstProt protocol for tests TstProt *string // TstLcl local socket for tests TstLcl *string // TstRmt remote socket for tests TstRmt *string // TstMsg messages for tests TstMsg *string // TstRoot root dir for tests TstRoot *string // TstClntNo number of clients for tests TstClntNo *int // TstMsgCount number of messages for tests TstMsgCount *int // TstTimeout number of seconds as timeout for tests TstTimeout *int // TstTO timeout duration for tests TstTO time.Duration // TstT direct pointer to tests. better not to be used TstT *testing.T )
var ( // AntiFlood is the limit of traffic from a peer AntiFlood struct { // Limit is for incoming traffic per second. // negative values means limitless. // 0=any incoming traffic causes disconnection Limit int64 // Period is to disconnect the peer immediatelyi, // if it connects again since previous flood. // non-positive values means forever. Period int64 // contains filtered or unexported fields } )
var (
// CfgStruc config structure
CfgStruc ezcommCfg
)
var FlowReaderNew func(string) (io.ReadCloser, error)
FlowReaderNew creation of a reader
var FlowWriterNew func(string) (io.WriteCloser, error)
FlowWriterNew creation of a writer
Functions ¶
func BulkFile ¶
BulkFile parses data into meaningful parts IsDataFile() must be called beforehand to ensure min length
func Client ¶
func Client(logFunc FuncLog, connFunc FuncConn, network, rmtAddr string, lstnFunc func(logFunc FuncLog, connFunc FuncConn, conn net.Conn, rmtAddr [2]string)) ( conn net.Conn, err error)
Client is mainly for TCP and Unix(not -gram). It ends immediately.
lstnFunc() needs to handle procedures afterwards. returned conn needs to Close() by user.
UDP, IP and Unixgram will be tricky to track peer information,
and preferrably use Listen*()
func Connected1Peer ¶
Connected1Peer works for TCP and UDP, when remote does not change Parameters:
logFunc for logging connFunc is callback function upon entrance of this function. It blocks the routine. If flood detected, it is called with local and remote addresses, requested protocol and address, and nil channels eztools.ErrAccess is sent to chan[1]. Network failure after the socket is closed cannot be matched, if not net.ErrClosed or io.EOF, so it is sent to chan[1] directly. conn is the connection addrReq is address user requested, and varies between local/remote, when user creates a server (listen) or a client -> caller: connFunc(), FlowChnRcv, FlowChnSnd, FlowChnEnd <- caller: FlowChnSnd, FlowChnEnd // this may block routine from exiting, if too much incoming traffic not read
func ConnectedUDP ¶
func ConnectedUDP(logFunc FuncLog, chn [2]chan RoutCommStruc, conn *net.UDPConn)
ConnectedUDP works for UDP, when remote can change
It blocks.
chn[1] -> caller: FlowChnRcv, FlowChnSnd, FlowChnEnd chn[0] <- caller: FlowChnSnd, FlowChnEnd
func Deinit4Tests ¶
func Deinit4Tests()
Deinit4Tests to use between multiple tests matching Init4Tests
func GetAvailFileName ¶
GetAvailFileName returns fn, if not exists, or, fn_addr_ with time appended If both exist, append it with a number in addition. Return values: file name and whether an available name found
func I18nLoad ¶
I18nLoad loads a language Parameter: name of the language, as a param of eztools.AddLanguage.
It should be locale.
Return values: input language, or detected one if no param input.
func Init4Tests ¶
Init4Tests parse flags, that are introduced from InitFlags4Tests() included in init()
func InitFlags4Tests ¶
func InitFlags4Tests()
InitFlags4Tests needs to be included in init() from a test file, to be parsed in Init4Tests() prot: protocol, tcp, tcp4, tcp6, unix or unixpacket lcl: local address rmt: remote address msg: messages to send root: root dir for http server timeout: in seconds verbose: verbose level msgCount: number of messages to send per client for TestSvrCln quan: quantity of clients
func IsDataFile ¶
IsDataFile checks whether received data a file (piece) It does not guarantee successful parsing into meaningful parts.
func ListSystemFonts ¶
ListSystemFonts get all system fonts with extensions
func ListenIP ¶
ListenIP listens to IP. It ends immediately. Parameters:
network is socket type, "ip", "ip4" or "ip6" address is for local, [IP or DN][:protocol number or name]
func ListenTCP ¶
func ListenTCP(logFunc FuncLog, connFunc FuncConn, network, address string, accepted func(FuncLog, FuncConn, net.Conn, [2]string), errChan chan error) ( net.Listener, error)
ListenTCP listens to TCP. It ends immediately. Simply close the listener to stop it.
Parameters: network is socket type, "tcp", "tcp4" or "tcp6" accepted() needs to handle procedures for incoming connections. can be nil. It blocks listening routine, so that errChan gets feedback always before accepted(). connFunc is for accepted() only. errChan sends Accept errors
func ListenUDP ¶
ListenUDP listens to UDP. It ends immediately.
*net.UDPConn needs to handle procedures afterwards.
Parameters:
network is socket type, "udp", "udp4" or "udp6" address is for local, [IP or DN][:port number or name]
func ListenUnixgram ¶
ListenUnixgram listens to unixgram. It ends immediately. Parameters:
network is socket type, "unixgram" address is for local, [IP or DN][:port number or name]
func MatchFontFromCurrLanguageCfg ¶
func MatchFontFromCurrLanguageCfg()
MatchFontFromCurrLanguageCfg matches font for current language in config
func MatchSystemFontsFromIndex ¶
MatchSystemFontsFromIndex returns font path from index into fontList[0 or 1]
func MatchSystemFontsFromPath ¶
MatchSystemFontsFromPath is reverse function for matchSystemFontsFromIndex Return value: eztools.InvalidID if not found
func MdnsClient ¶
func MdnsClient(localName string, chnAddr chan netip.Addr, chnStp chan struct{}, chnErr chan error, timeout time.Duration)
MdnsClient creats a client and queries Parameters: localName must match server channels can be nil
func MdnsServer ¶
func MdnsServer(localName string, chnStp chan struct{}, chnErr chan error) (server *mdns.Conn, err error)
MdnsServer creats a server and waits for queries Parameters: chnErr can be nil, others must not Return values: not to be used, except for internal MdnsClient for internal usage, when localName is empty and chnStp is nil, server does not wait and is for MdnsClient.
func ReaderCfg ¶
func ReaderCfg(rdr io.ReadCloser, fallbackLang string) error
ReaderCfg reads config from a Reader Closer is closed before returning
func SetLog ¶
SetLog sets a writer or file as log date and time will be prefixed to the file; none to a writer, otherwise.
func SndFile ¶
SndFile sends a file without splitting. Parameter: rdr is closed before returning Return value:
ErrOutOfBound if file+prefix larger than FlowRcvLen other error from os.Stat(), ioutil.ReadFile(), or prefix4File() value from proc()
func Sz41stChunk ¶
Sz41stChunk returns max data size to transfer in first chunk
if input file name is too long, a valid one is returned
func TryOnlyChunk ¶
TryOnlyChunk try to read the file in one chunk Parameter: rdr is closed before returning Return values:
a possible long file name read buffer ErrOutOfBound if no valid data fits ErrInvalidInput file larger than one chunk
func WriterCfg ¶
func WriterCfg(wrt io.WriteCloser) error
WriterCfg to save config using Writer Closer is closed before returning
Types ¶
type FlowConnStruc ¶
type FlowConnStruc struct { // Cmt = comments Cmt string `xml:",comment"` // Txt is not used Txt string `xml:",chardata"` Name string `xml:"name,attr"` Protocol string `xml:"protocol,attr"` Addr string `xml:"address,attr"` Peer string `xml:"peer,attr"` Block bool `xml:"block,attr"` // TODO: use Wait? Wait string `xml:"wait,attr"` Steps []FlowStepStruc `xml:"step"` // contains filtered or unexported fields }
FlowConnStruc a connection in a flow
func (*FlowConnStruc) Connected ¶
func (conn *FlowConnStruc) Connected(logFunc FuncLog, connFunc FuncConn, connTCP net.Conn, addr [2]string)
Connected when connected in flow
func (*FlowConnStruc) LockLog ¶
func (conn *FlowConnStruc) LockLog(nm string, lck bool)
LockLog un-/locks for log
func (*FlowConnStruc) ParsePeer ¶
func (conn *FlowConnStruc) ParsePeer(flow FlowStruc)
ParsePeer parses peer in struct
func (*FlowConnStruc) Run ¶
func (conn *FlowConnStruc) Run(flow *FlowStruc)
Run runs a flow to be run by RunFlow, b/c no (de-)init for channels
func (*FlowConnStruc) RunCln ¶
func (conn *FlowConnStruc) RunCln(flow FlowStruc)
RunCln runs a client to be run by FlowConnStruc.Run(), b/c no (de-)init for channels
func (*FlowConnStruc) RunSvr ¶
func (conn *FlowConnStruc) RunSvr(flow FlowStruc)
RunSvr supports TCP & UDP only. TODO: IP & Unix to be run by FlowConnStruc.Run(), b/c no (de-)init for channels
func (FlowConnStruc) Step1 ¶
func (conn FlowConnStruc) Step1(flow *FlowStruc, step *FlowStepStruc)
Step1 runs 1 step in flow
func (FlowConnStruc) StepAll ¶
func (conn FlowConnStruc) StepAll(flow *FlowStruc, steps []FlowStepStruc)
StepAll runs steps in flow
func (*FlowConnStruc) Wait4 ¶
func (conn *FlowConnStruc) Wait4(flow FlowStruc) (ret string)
Wait4 waits for chan from server
type FlowStepStruc ¶
type FlowStepStruc struct { // Cmt = comments Cmt string `xml:",comment"` // Txt is not used Txt string `xml:",chardata"` Act string `xml:"action,attr"` // Name if not null, this structure will be mapped to Vals Name string `xml:"name,attr"` // Dest will be updated upon UDP receive action, if it is a variable Dest string `xml:"dest,attr"` Data string `xml:"data,attr"` // Loop rounds to repeat this step // 0, 1: no loop // > 1: number of rounds // < 0: infinitely Loop int `xml:"loop,attr"` Block bool `xml:"block,attr"` // Steps: sub steps triggered Steps []FlowStepStruc `xml:"step"` }
FlowStepStruc a step in a flow
func (FlowStepStruc) ParseData ¶
func (step FlowStepStruc) ParseData(flow FlowStruc, conn FlowConnStruc) (string, int)
ParseData parses data in step Return values:
1st. is one of following data string in form of a simple string data string where substituted if possible, the value of a member of FlowConnStruc or FlowStepStruc for <string> in <FlowVarSign><xml tag name of FlowConnStruc or FlowStepStruc><FlowVarSep><string><FlowVarSign> file name for <string> in <FlowVarSign><FlowVarFil><FlowVarSep><string><FlowVarSign> 2nd. 0: a string 1(=difference from FlowChnRcv to FlowChnRcvFil): a file name 2: a script name
func (FlowStepStruc) ParseDest ¶
func (step FlowStepStruc) ParseDest(flow FlowStruc, conn FlowConnStruc) *net.UDPAddr
ParseDest parses destination in flow
type FlowStruc ¶
type FlowStruc struct { // Root of the XML Root xml.Name `xml:"ezcommFlow"` // Cmt = comments Cmt string `xml:",comment"` // Txt is not used Txt string `xml:",chardata"` Conns []FlowConnStruc `xml:"conn"` Vals map[string]*FlowStepStruc }
FlowStruc defines the structure of a flow xml
func ReadFlowFile ¶
ReadFlowFile reads flow from a file
func ReadFlowReader ¶
func ReadFlowReader(rdr io.ReadCloser) (flow FlowStruc, err error)
ReadFlowReader reads flow from a reader
func (FlowStruc) ParseVar ¶
ParseVar parses a string of a simple string or
<FlowVarSign>[<xml tag name of FlowConnStruc/FlowStepStruc><FlowVarSign>]<string><FlowVarSign> fun() is invoked for matched FlowConnStruc, with index of it in FlowStruc.Conns and <string>
Return values:
1st. If FlowConnStruc is matched, the value of its member whose xml tag is <string> Otherwise, the input <string> 2nd. FlowParseVal*, that's to say, FlowParseValSimple, FlowParseValSign, or FlowParseValVar
type Fonts ¶
type Fonts struct { // Cmt is not used Cmt string `xml:",comment"` // Locale is like zh-TW Locale string `xml:"locale,attr"` // Font is built-in names for fonts, which are locales, // or paths of fonts Font string `xml:"font,attr"` }
Fonts is a font-locale match
type FuncConn ¶
type FuncConn func(addr [4]string, chn [2]chan RoutCommStruc)
FuncConn is run when Connected. addr=address info.
[0]: parsed local [1]: remote [2]: requested protocol [3]: requested address
close(chan[...]) upon exiting!
[0]: to ezcomm [1]: from ezcomm
type HTTPSvr ¶
type HTTPSvr struct {
// contains filtered or unexported fields
}
HTTPSvr Serv=serve Shut=shutdown
func (*HTTPSvr) FS ¶
func (svr *HTTPSvr) FS(relativePath, rootPath string, fs http.FileSystem)
FS sets a static file system Parameters: fs OR rootPath: to use a filesystem or gin's default
func (*HTTPSvr) GET ¶
func (svr *HTTPSvr) GET(relativePath string, fun HTTPSvrProcFunc)
GET sets a GET handler
func (*HTTPSvr) POST ¶
func (svr *HTTPSvr) POST(relativePath string, fun HTTPSvrProcFunc)
POST shows a text input
type HTTPSvrBody ¶
type HTTPSvrBody struct { // Tp type, one of HTTPSvrBodyString, HTTPSvrBodyHTML // and HTTPSvrBodyJSON Tp int // Str for HTTPSvrBodyString and HTTPSvrBodyHTML Str string // JSON for HTTPSvrBodyJSON, map[string]any JSON gin.H }
HTTPSvrBody body for HTTPSvr
type HTTPSvrProcFunc ¶
type HTTPSvrProcFunc func(string, *http.Request, func(string) string) (int, HTTPSvrBody, map[string]string)
HTTPSvrProcFunc method proc func type for HTTPSvr
Parameters:
remote IP request func to get values by keys
Return values: response code, body, headers. 204 is default if fun is nil.
type RoutCommStruc ¶
type RoutCommStruc struct { // ReqAddr is address from user ReqAddr string // Act action Act int // PeerUDP is filled, and required for FlowChnSnd by EZ Comm PeerUDP *net.UDPAddr // PeerTCP is filled, but not required by EZ Comm PeerTCP net.Addr // Data is I/O raw message Data []byte // Resp for SvrTcp and flow only Resp chan RoutCommStruc Err error }
RoutCommStruc is communication struct between EZComm and user
type SvrTCP ¶
type SvrTCP struct { // LogFunc is not routine safe, for logging // behavior undefined if not set LogFunc FuncLog // ActFunc is for FlowChnRcv, FlowChnEnd, FlowChnSnd to user. // behavior undefined if not set ActFunc func(RoutCommStruc) // ConnFunc runs upon an incoming connection // It must not block // also runs on listening, to tell user of the actual address // behavior undefined if not set ConnFunc func([4]string) // contains filtered or unexported fields }
SvrTCP handles all clients and uses requested address to match them with user
routines SvrTCP | ezcomm ======= | =======
listening (Connected) | connected:* ListenTcp ConnectedTcp:2 ===================== | ===================================
|-----------------------------------| 1 incoming connection |--------------> <-----[2]channel, ezcomm------------| <-channel[0]|channel[1]-> incoming traffic <-----chnLstn-----------|<-channel[1], ezcomm---|
ChnConn[1]
outgoing traffic |------------------channel[0], ezcomm---------->|
ChnConn[0]
|----------break 1 connection------------------>^
ChnConn[0]
<----------1 connection broken-----------------^
ChnConn[1]
|--break 1 connection ->^ |close listener
ChnConn[0]
listening stopped, sending chnSvr^ ^ (listening stopped and no connections in existence)
ChnConn[1]
func (*SvrTCP) HasStopped ¶
HasStopped whether SvrTCP has Stop-ped
func (*SvrTCP) Listen ¶
Listen returns whether successfully listening ConnFunc is called before returning, with only listening address as the first member of the slice. ConnFunc may be called after a client incomes and is reported because of routine schedules.