Connect to the MPD server

Property definitions

mpd $ MPDConnection :: connect
	# Connect to the MPD server
	fun connect
	do
		var p: nullable TCPStream = null

		p = new TCPStream.connect(host, port)
		assert p.connected

		sys.nanosleep(0,5000)

		var rep = p.read(1024)
		assert not rep.is_empty
		if not rep.has_prefix("OK") then
			print "MPD responded {rep}"
			abort
		end

		socket = p

		var password = password
		if password != null then
			write_and_check("password {password}\n")
		end
	end
lib/mpd/mpd.nit:40,2--63,4