Setting up a server basically requires the following steps:
- Open socket with socket()
- Bind socket to an address (usually INADDR_ANY) and a specific port with bind()
- Listen to the socket with listen()
- Accept a connection with accept(). This returns a new socket number (the client socket)
- Now you can receive data from the client socket with recv() and send data with send().
To send a file to the client, just read from the file for example line by line and then send it to the socket with send().
Of course you need to communicate the file name and size before you start sending. (Or use EOF character at the end of file).
For more information, see:
msdn: Getting Started with Winsock