[remote] add a onListen func

This commit is contained in:
chzyer 2016-03-31 14:20:14 +08:00
parent 5652dc7c25
commit a5bc4d464a
1 changed files with 6 additions and 1 deletions

View File

@ -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 {