connection.cpp: fixes after code audit
connection.cpp: fix readline()

Requested by and OK @bassosimone.