Accept a connection on listener

By default, it creates a new NativeBufferEvent and calls spawn_connection.

Property definitions

libevent $ ConnectionFactory :: accept_connection
	# Accept a connection on `listener`
	#
	# By default, it creates a new NativeBufferEvent and calls `spawn_connection`.
	fun accept_connection(listener: ConnectionListener, fd: Int, addrin: Pointer, socklen: Int)
	do
		var base = listener.base
		var bev = new NativeBufferEvent.socket(base, fd, bev_opt_close_on_free)

		# Human representation of remote client address
		var addr_len = 46 # Longest possible IPv6 address + null byte
		var addr_buf = new CString(addr_len)
		addr_buf = addrin_to_address(addrin, addr_buf, addr_len)
		var addr = if addr_buf.address_is_null then
				"Unknown address"
			else addr_buf.to_s

		var conn = spawn_connection(bev, addr)
		bev.enable ev_read|ev_write
		bev.setcb conn
	end
lib/libevent/libevent.nit:487,2--506,4