示例#1
0
文件: client.go 项目: rainkid/pconn
func NewClient(manager *Manager, conn *net.TCPConn) *Client {
	ip := strings.Split(conn.RemoteAddr().String(), ":")
	return &Client{
		manager: manager,
		host:    ip[0],
		uhost:   utils.Ip2Uint32(ip[0]),
		port:    ip[1],
		conn:    conn,
	}
}
示例#2
0
文件: server.go 项目: rainkid/pconn
func NewServer(manager *Manager, conn *net.TCPConn) *Server {
	ip := strings.Split(conn.RemoteAddr().String(), ":")
	port, _ := strconv.ParseUint(ip[1], 10, 64)

	return &Server{
		manager:   manager,
		host:      ip[0],
		uhost:     utils.Ip2Uint32(ip[0]),
		port:      uint32(port),
		conn:      conn,
		lastHeart: time.Now().Unix(),
		stat:      nil,
	}
}