mirror of https://github.com/chzyer/readline.git
[remote] add a onListen func
This commit is contained in:
parent
5652dc7c25
commit
a5bc4d464a
|
@ -394,11 +394,16 @@ func (r *RemoteCli) Serve() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ListenRemote(n, addr string, cfg *Config, h func(*Instance)) error {
|
func ListenRemote(n, addr string, cfg *Config, h func(*Instance), onListen ...func(net.Listener) error) error {
|
||||||
ln, err := net.Listen(n, addr)
|
ln, err := net.Listen(n, addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if len(onListen) > 0 {
|
||||||
|
if err := onListen[0](ln); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
conn, err := ln.Accept()
|
conn, err := ln.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue