Serve accepts incoming SSH connections on the listener l, creating a new connection goroutine for each. The connection goroutines read requests and then calls handler to handle sessions. Handler is typically nil, in which case the DefaultHandler is used.
(l net.Listener, handler Handler, options ...Option)
| 89 | // then calls handler to handle sessions. Handler is typically nil, in which |
| 90 | // case the DefaultHandler is used. |
| 91 | func Serve(l net.Listener, handler Handler, options ...Option) error { |
| 92 | srv := &Server{Handler: handler} |
| 93 | for _, option := range options { |
| 94 | if err := srv.SetOption(option); err != nil { |
| 95 | return err |
| 96 | } |
| 97 | } |
| 98 | return srv.Serve(l) |
| 99 | } |
| 100 | |
| 101 | // ListenAndServe listens on the TCP network address addr and then calls Serve |
| 102 | // with handler to handle sessions on incoming connections. Handler is typically |