send file reliably on udp/tcp sockets