Fix libxcb on Windows
Fix libxcb on Windows. The first commit fixes compile errors (and trivial runtime errors, such as calling close instead of closesocket). The second commit rewrites the writev() emulation in write_vec() to fix a couple of data corruption bugs.