|
CS473 - Computer Networks
| Displaying exercises/e5/files/serv.c
/* Include here */
#define K 1024
/**
* The port number for your "server" is the same as the digits in your cs473
* account.
*/
#define PORT 473##
/**
* Create a function to handle a client connection. It should take two
* parameters, the client socket descriptor and the path to the file to send
* to the client. Open the file and write the data in it to the client, then
* close the descriptors.
*/
/**
* serv.c:
* Get the name of a file from the command line and setup a server socket and
* listen for connections, accepting them in a forever loop. Hand each
* connection off to the client handling function defined above. This program
* should not exit.
*/
int main(int argc, char *argv[])
{
/* Create a SOCK_STREAM internet socket: */
/**
* Set the socket option SO_REUSEADDR using the setsockopt(2) system call.
* The SO_REUSEADDR option is documented in the socket(7) manual page.
*/
/**
* Setup server address, bind to any address on port defined by the PORT
* #define above:
*/
/* Start listening for connections using the listen(2) call: */
for(;;) {
/**
* accept(2) a connection here, pass the new descriptor with the name of the
* file to send to the client handing function.
* Do this forever.
*/
}
// Not reached:
return 0;
}
|