For files with non-text contents you could write/read bytes instead of characters.
Otherwise the code would be very much like any other client/server socket program.

Do a Search here or Google...