ToSend << Buffer
This code writes Buffer as a C-style string, so it stops after the first '\0'.
A simple fix:
ToSend << std::string(Buffer, Buffer + sizeof(Buffer));
But a better strategy would be to simply get rid of sf::Packet, it's useless here since you send raw data. No type or endianness is involved.
while (File.read(Buffer, sizeof(Buffer)))
{
Socket.Send(Buffer, sizeof(Buffer));
}
while(true)
{
char Buffer[4096];
std::size_t Size = 0;
Client.Receive(Buffer, sizeof(Buffer), Size);
OutputFile.write(Buffer, Size);
}
By the way, you don't need a dynamic allocation for Buffer.
char Buffer[4096];
You don't need to clear the buffer, but rather use the number of bytes actually read from the file -- but I don't remember how it is done with std::istream.
Don't forget to check the result of socket functions (Send, Receive) for failure or disconnection.