1. Yes, just the way HTTP does it so no problem.
2. Not sure I understand the question. You can just use strings containing codes plus text as responses; again the same as HTTP.
2(again). Not really sure but
UNIX Network Programming[
^] contains a wealth of useful information.