-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (31 loc) · 1.07 KB
/
Copy pathmain.cpp
File metadata and controls
36 lines (31 loc) · 1.07 KB
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
#include "FileReader.h"
#include "FileWriter.h"
/*
* In order to run this executable, arguments need to be given in the following order shown below.
*
* ./file_transfer -tcp -port=5000 -s -file="pathname"
* ./file_transfer -tcp -port=5000 -c -file="pathname"
* ./file_transfer -udp -port=5000 -s -file="pathname"
* ./file_transfer -udp -port=5000 -c -file="pathname"
*/
int main(int argc, char * argv[]) {
socket_type my = check(argc, argv);
if (!my.error) {
if (my.is_server) {
// initiate start by user input
FileReader my_filereader(my.pathname.c_str());
FileReaderSocket my_filereader_socket(my_filereader);
my_filereader_socket.init(my.s_type, my.is_server, my.port);
my_filereader.start();
}
else {
FileWriterSocket my_filewriter_socket(my.s_type, my.is_server, my.port);
FileWriter my_filewriter(my_filewriter_socket, my.pathname.c_str());
my_filewriter_socket.start();
}
}
else {
perror("Wrong input!");
}
return 0;
}