import telnetlib


def test_connection(hostname, port):
	"""Tests that a connection is reachable using telnet"""
	t = telnetlib.Telnet()
	try:
		t.open(hostname, port)
		t.close()
		return None
	except Exception as e:
		return "couldn't connect to {}:{} - {}".format(hostname, port, e)