Skip to content

Commit 356716c

Browse files
committed
Update README with sendfile, recvfile instructions
1 parent d0c3fce commit 356716c

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ make clean # cleanup
88

99
export LD_LIBRARY_PATH=./src/:$LD_LIBRARY_PATH # export the library path
1010

11-
./progs/server # start the server
12-
./progs/client # start the client
11+
progs/server # start the server
12+
progs/client # start the client
13+
14+
progs/sendfile # start the sendfile server
15+
progs/recvfile "file/to/get" "file/to/saveas" # receive the file
1316
```
1417

1518
### Progress

progs/recvfile.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,24 @@ int main(int argc, char *argv[])
5050

5151
freeaddrinfo(result);
5252

53-
/* send, recv */
53+
/* get file names */
5454
char reqfile[BUFFER_SIZE];
5555
char filename[BUFFER_SIZE];
56-
printf("\n\tGet file: ");
57-
scanf("%s", reqfile);
58-
printf("\tSave as: ");
59-
scanf("%s", filename);
56+
if (argc > 0) {
57+
strcpy(reqfile, argv[1]);
58+
} else {
59+
printf("\n\tGet file: ");
60+
scanf("%s", reqfile);
61+
}
62+
if (argc > 1) {
63+
strcpy(filename, argv[2]);
64+
} else {
65+
printf("\tSave as: ");
66+
scanf("%s", filename);
67+
}
6068
udt_send(sock, reqfile, strlen(reqfile), 0);
6169

62-
/* send file */
70+
/* recv file */
6371
int filefd = open(filename, O_WRONLY | O_TRUNC | O_CREAT);
6472
int64_t offset = 0;
6573
if (filefd < -1) return 2;

progs/sendfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int main(int argc, char *argv[])
7878
udt_recv(conn, filename, BUFFER_SIZE, 0);
7979
printf("\tFilename: %s\n\n", filename);
8080

81-
/* recv file */
81+
/* send file */
8282
int filefd = open(filename, O_RDONLY);
8383
int64_t offset = 0;
8484
if (filefd < 0) return 2;

0 commit comments

Comments
 (0)