I wonder if you could get some inspiration from the linda library? I'm sure it reads terms from sockets.
For sending terms down sockets and rebuilding them at the other end the best thing to use is fast_read/1 and fast_write/1, which efficiently translate terms into strings and back ("marshalling and unmarshalling"). This is what we use in most socket interfaces (sql, java, tcltk, distributed execution, ...).
By the way, note that the linda library is obsolete (it is superceded by communication via concurrent facts, i.e., in Ciao the Prolog database >is< the blackboard!).