I need to be able to send a file across a network using sockets and C/C++ and BSD environment. My current method involves simply reading the binary data of the file and sending that over a socket. Then having the other end write that into a new file. However that's alot of data traveling through the socket. This seems prone to buffer overflows because it seems hard to set a limit for the buffer (this could result in files being to big to transfer). Is there a better way of sending documents and programs over a network?