|
CS473 - Computer Networks
| Displaying exercises/e5/files/get.c
/* Includes go here */
/**
* The port number for your "server" is the same as the digits in your cs473
* account.
*/
#define PORT 473##
/*
* get.c:
* A program to connect to a server (hostname provided as the first command
* line parameter) and receive data into a file (name provided as the second
* command line parameter.) Print a usage and exit if there are not enough
* parameters.
*
* Usage: get <hostname> <filename>
*/
int main(int argc, char *argv[])
{
/**
* Use open to open the file specified by argv[2] for writing, create the
* file if it doesn't exist and truncate the file if it does.
* Print an error message and exit if the open fails.
*/
/* Create a SOCK_STREAM internet socket: */
/* Setup the severs address, use gethostbyname(3) to get the address: */
/* Use connect(2) to connect to the server: */
/**
* In a loop, read K sized buffers from the socket and write the data into
* the file until the socket connection is closed. Make sure to only write
* as much data into the file as was actually read from the socket.
*/
return 0;
}
|