-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbirbd.cpp
More file actions
41 lines (37 loc) · 1.18 KB
/
birbd.cpp
File metadata and controls
41 lines (37 loc) · 1.18 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
37
38
39
40
41
#include "Client.hpp"
#include "Server.hpp"
#include <iostream>
int main(int argc, char** argv)
{
/* Act as a server */
if (argc == 2 && !strcmp("--server", argv[1]))
{
Server server(1500);
server.listen();
return 0;
}
/* Send a message to the server */
if (argc == 3)
{
Client client(argv[1], "1500");
std::string response = client.connect(argv[2]);
std::cout << response << std::endl;
/* If the response was NULL, return 1
* in all other cases return 0 */
if (response == "NULL")
return 1;
else
return 0;
}
else
{
std::cout << "Usage: birbd [ip address] [--server|message]\n\n"
<< "If --server option is used, birbd will act as a server. IP-address isn't needed in server-mode\n\n"
<< "Valid messages (values between [] are placeholders):\n"
<< " ping the server should answer with pong\n"
<< " has_package;[tarball_name];[md5_checksum] the server will answer either positive or negative\n"
<< " depending on if the server had the tarball or not\n\n"
<< "If the server answers NULL, something went wrong or the query was invalid\n";
}
return 0;
}