What does netstat show the state of the conn being when this error state happens? Also do you have control of the sending side of this? if so, it might make sense to do a heartbeat (a dummy packet that gets discarded in the scope of the log) every few minutes that forces all firewalls etc between the two hosts to think that the connection is active over long periods of inactivity.
Also, getline is fine. And since you don't need this to timeout at all, you can use undef for the timeout value to turn off timeouts completely.