reads data from tcp socket