aboutsummaryrefslogtreecommitdiff
path: root/pa1_file_transfer/readme.md
blob: 3ef2523f67b85cf57bbcecf9c81f6c04f4528d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## File Transfer
### Programming Assignment 1 - UDP Sockets

In this assignment, you will build two programs in C:
- a client which will accept user input and then send requests over UDP
- a server which will return responses to those commands, also over UDP

The client and server will implement functionality similar to FTP, which provides means for a
client to transfer files to and from a remote server. In our case, we will implement a subset of
some typical FTP commands and use sockets to communicate between the client and server.

### Client
On invocation, the client must take two command line arguments
1. an IP address
2. a port number where the server side code is running

```shell
$ cc uftp_client.c -o client
$ ./client 192.168.1.101 5001
```

Your client should prompt the user to type any of the following commands:
- get [filename]
- put [filename]
- delete [filename]
- ls
- exit

After verifying the syntax of the user's input is correct, your client will send a datagram to
the server indicating which operation is required any any other data or parameters needed to
satisfy the request. the client must then waitfor the server's response. if the server fails to
respond after an appropriate amount of time, an error message must be emitted to stderr.

Once the server respons, your client will print an appropriate message to stdout, indicating the
result of the requested operation. In the case of `put`, the client should source the indicated
file in the current working directory. In the case of `get`, the client should store the returned
file in the current working directory. For the `exit` command, the client should exit gracefully
after the server acknowledges that the client is done.

### Server
The server must take one command line argument
1. a port number for the server to use. You should choose ports greater than 5000

```shell
$ cc uftp_server.c -o server
$ ./server 5001
```

Your server should wait for a UDP connection after binding to the requested port. Depending on
the commands received, the server responds to the client's request in the following manner:
- get [filename]: the server transmits the requested file to the client
- put [filename]: the server receives the transmitted file from the client and stores it locally
- delete [filename]: the server deletes the file if it exists
- ls: the server should search all the files it has in its current working directory and sent a
list of all these files to the client
- exit: the server should acknowledge that the client is done with a goodbye message.

For any other command, the server should respond that the given command was not understood. In
all of these cases, if the server is unable to perform an operation, it should respond to the
client indicating a failure.