Added separate s_eof from agent. On any kind of error, just close the
socket immediately and set it to -1, which indicates that the
connection is dead.