File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,11 @@ make clean # cleanup
8
8
9
9
export LD_LIBRARY_PATH=./src/:$LD_LIBRARY_PATH # export the library path
10
10
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
13
16
```
14
17
15
18
### Progress
Original file line number Diff line number Diff line change @@ -50,16 +50,24 @@ int main(int argc, char *argv[])
50
50
51
51
freeaddrinfo (result );
52
52
53
- /* send, recv */
53
+ /* get file names */
54
54
char reqfile [BUFFER_SIZE ];
55
55
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
+ }
60
68
udt_send (sock , reqfile , strlen (reqfile ), 0 );
61
69
62
- /* send file */
70
+ /* recv file */
63
71
int filefd = open (filename , O_WRONLY | O_TRUNC | O_CREAT );
64
72
int64_t offset = 0 ;
65
73
if (filefd < -1 ) return 2 ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ int main(int argc, char *argv[])
78
78
udt_recv (conn , filename , BUFFER_SIZE , 0 );
79
79
printf ("\tFilename: %s\n\n" , filename );
80
80
81
- /* recv file */
81
+ /* send file */
82
82
int filefd = open (filename , O_RDONLY );
83
83
int64_t offset = 0 ;
84
84
if (filefd < 0 ) return 2 ;
You can’t perform that action at this time.
0 commit comments