I've been taking a long hard look at the protocol layer. It has evolved over a long time without any particular direction, and the result is, to say the least, not very organized. These patches take a first step at cleaning up the mess by abstracting out socket operations from the rest of the code. The purpose of this is to allow us to slot in a different connection layer under the library-side protocol (ie. one based on virStreamPtr for remote libvirt connections). But the refactoring is also useful both because it simplifies the code and because it would make it easier to add multiple daemon connections. These changes pass all the tests with both libvirt & appliance attach-methods, and with valgrind; *except* for tests/mount-local -- but that test was failing intermittently before this change for reasons which I still don't quite understand. Rich.