Sending files over a socket efficiently and cross-platform