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.
nnet/client_tcp.go

24 lines
482 B
Go

package nnet
import (
"git.noahlan.cn/noahlan/nnet/conn"
"git.noahlan.cn/noahlan/ntool/nlog"
"net"
)
// DialTCP 连接服务器
func (ngin *Engine) DialTCP(addr string) (*conn.Connection, error) {
err := ngin.setup()
if err != nil {
nlog.Errorf("%s failed to setup server, err:%v", ngin.LogPrefix(), err)
return nil, err
}
rc, err := net.Dial("tcp", addr)
nlog.Must(err)
nlog.Infof("%s now connect to %s...", ngin.LogPrefix(), addr)
return ngin.handle(rc), nil
}