If you really want to keep to pure client-server paradigm, server cannot request anything. Server is purely passive. If you want to implement some inversion of control, it's fine but don't call it client and server. You application does not need it.
— Client: I'm sending a file: name is N, size is X bytes;
— Server: confirmed; (starts reading from a network stream, this is blocking operation);
— Client: sends chunk;
— Server: confirmed; (previous chuck is appended to file stream);
…
— Client: sends chunk; (no need to tell its the last one, server knows that from the size);
— Server: last chunk confirmed; (writes last chunk, closes file stream).
I would advice you use
TcpListener/TcpClient
.
You can use other levels of networking, see my past answers:
how i can send byte[] to other pc[
^],
Communication b/w two Windows applications on LAN.[
^].
Most important aspect here is threading. Normally, server part need two separate threads: one is listening for new connections, another one traverses all connected client and perform some application-level protocol by reading/writing from/to each network stream.
See my design sketch in my past answer here:
Multple clients from same port Number[
^].
—SA