EOF or End of file in linux is usually when getChar returns -1. But you can't actually send -1 with a socket. All bytes must be 0-255.
End of file in DOS was ASCII character 'x04', also known as End of Transmission or ^D in linux. You could send that and check for that character. But the problem is that you said binary. It's very easy for a binary file to have a 0x04 byte some where inside which will cut off your file. Its best to just send length of the file first. Read the length and then read the number of bytes you need for the rest of the file.
