More correctyly handles socket timeout