// Turn on listener by address.
// Client handle function need be not null.
Turn on listener by address.
Client handle function need be not null.
// Turn on listener by address . // Client handle function need be not null .
func (node *Node) Listen(address string) error {
	listen, err := net.Listen("tcp", address)
	if err != nil {
		return err
	}
	defer listen.Close()
	for {
		conn, err := listen.Accept()
		if err != nil {
			break
		}
		if node.isMaxConnSize() {
			conn.Close()
			continue
		}
		id := encoding.Base64Encode(crypto.Rand(gopeer.Get("RAND_SIZE").(uint)))
		node.setConnection(id, conn)
		go node.handleConn(id)
	}
	return nil
}
func ( node * Node ) Listen ( address string ) error { listen , err := net . Listen ( " " , address ) if err != nil { return err } defer listen . Close ( ) for { conn , err := listen . Accept ( ) if err != nil { break } if node . isMaxConnSize ( ) { conn . Close ( ) continue } id := encoding . Base64Encode ( crypto . Rand ( gopeer . Get ( " " ) . ( uint ) ) ) node . setConnection ( id , conn ) go node . handleConn ( id ) } return nil }
Turn on listener by address.
Turn on listener by address .