As already stated it does not do that. It wrecks the file by overwriting the first bytes and then dumps that into the socket.
I'm not sure how you wish to differentiate between a "chat message" and a "file" on the receiving end if you are not using any kind of protocol for communication but instead you rely on the broken fortune cookie example without even understanding how it works.
Bookmarks