You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
492 B
Go
24 lines
492 B
Go
package nnet
|
|
|
|
import (
|
|
"git.noahlan.cn/noahlan/nnet/connection"
|
|
"git.noahlan.cn/noahlan/ntool/nlog"
|
|
"net"
|
|
)
|
|
|
|
// Dial 连接服务器
|
|
func (ngin *Engine) Dial(addr string) (*connection.Connection, error) {
|
|
err := ngin.setup()
|
|
if err != nil {
|
|
nlog.Errorf("%s failed to setup server, err:%v", ngin.LogPrefix(), err)
|
|
return nil, err
|
|
}
|
|
|
|
conn, err := net.Dial("tcp", addr)
|
|
nlog.Must(err)
|
|
|
|
nlog.Infof("%s now connect to %s...", ngin.LogPrefix(), addr)
|
|
|
|
return ngin.handle(conn), nil
|
|
}
|