forked from mirror/readline
[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
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(onListen) > 0 {
|
||||
if err := onListen[0](ln); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for {
|
||||
conn, err := ln.Accept()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue