blob: c01dbb5adfadf76fff7cf9b332c24d6fbd9ccf8e (
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
|
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <exception>
#include "rl.h"
#include "sock.h"
int main(int argc, char** argv) {
if (argc < 2) {
printf("usage: %s addr [port]\n", argv[0]);
return EXIT_FAILURE;
}
// parse arguments
char* addr = argv[1];
uint16_t port = 9191;
if (argc >= 3) port = atoi(argv[2]);
PBSocket sock(addr, port);
try {
// connect to TCP socket (automatically spawns thread)
sock.sock_connect();
} catch (const std::exception& e) {
printf("error: %s\n", e.what());
return EXIT_FAILURE;
}
// enter main CLI (using GNU readline for comfyness)
return cli_main();
}
|