|
@@ -1,5 +1,5 @@
|
|
-#include <boost/program_options.hpp>
|
|
|
|
#include <boost/asio.hpp>
|
|
#include <boost/asio.hpp>
|
|
|
|
+#include <boost/program_options.hpp>
|
|
#include <cctype>
|
|
#include <cctype>
|
|
#include <iostream>
|
|
#include <iostream>
|
|
|
|
|
|
@@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
|
show_help(argv[0]);
|
|
show_help(argv[0]);
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// identify command, print error message if unknown
|
|
// identify command, print error message if unknown
|
|
COMMANDTYPES cmd = getCommand(argv[1], (strlen(argv[1]) == 1));
|
|
COMMANDTYPES cmd = getCommand(argv[1], (strlen(argv[1]) == 1));
|
|
switch (cmd) {
|
|
switch (cmd) {
|
|
@@ -107,7 +107,7 @@ int main(int argc, char **argv) {
|
|
show_help(argv[0]);
|
|
show_help(argv[0]);
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
// parse additional arguments, possibly drop this in the future for full
|
|
// parse additional arguments, possibly drop this in the future for full
|
|
// interactivity
|
|
// interactivity
|
|
try {
|
|
try {
|
|
@@ -130,18 +130,17 @@ int main(int argc, char **argv) {
|
|
socket.connect(tcp::endpoint(bai::ip::address::from_string(argv[2]), 1234));
|
|
socket.connect(tcp::endpoint(bai::ip::address::from_string(argv[2]), 1234));
|
|
std::printf("connected to %s - sending hello\n", argv[2]);
|
|
std::printf("connected to %s - sending hello\n", argv[2]);
|
|
bai::write(socket, bai::buffer("Client CONNECT test\n"), err);
|
|
bai::write(socket, bai::buffer("Client CONNECT test\n"), err);
|
|
- if(!err) {
|
|
|
|
- std::printf("OK: sent message\n");
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ if (!err) {
|
|
|
|
+ std::printf("OK: sent message\n");
|
|
|
|
+ } else {
|
|
std::printf("ERR: couldnt send message: %s\n", err.message().c_str());
|
|
std::printf("ERR: couldnt send message: %s\n", err.message().c_str());
|
|
}
|
|
}
|
|
bai::read(socket, recvbuf, bai::transfer_all(), err);
|
|
bai::read(socket, recvbuf, bai::transfer_all(), err);
|
|
- if(err && err != bai::error::eof) {
|
|
|
|
|
|
+ if (err && err != bai::error::eof) {
|
|
std::printf("ERR: couldnt recieve message: %s\n", err.message().c_str());
|
|
std::printf("ERR: couldnt recieve message: %s\n", err.message().c_str());
|
|
- }
|
|
|
|
- else {
|
|
|
|
- std::printf("OK: recieved message %s\n", bai::buffer_cast<const char*>(recvbuf.data()));
|
|
|
|
|
|
+ } else {
|
|
|
|
+ std::printf("OK: recieved message %s\n",
|
|
|
|
+ bai::buffer_cast<const char *>(recvbuf.data()));
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case CMD_DISCONNECT:
|
|
case CMD_DISCONNECT:
|
|
@@ -149,18 +148,17 @@ int main(int argc, char **argv) {
|
|
socket.connect(tcp::endpoint(bai::ip::address::from_string(argv[2]), 1234));
|
|
socket.connect(tcp::endpoint(bai::ip::address::from_string(argv[2]), 1234));
|
|
std::printf("connected to %s - sending goodbye\n", argv[2]);
|
|
std::printf("connected to %s - sending goodbye\n", argv[2]);
|
|
bai::write(socket, bai::buffer("Client DISCONNECT test\n"), err);
|
|
bai::write(socket, bai::buffer("Client DISCONNECT test\n"), err);
|
|
- if(!err) {
|
|
|
|
- std::printf("OK: sent message\n");
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ if (!err) {
|
|
|
|
+ std::printf("OK: sent message\n");
|
|
|
|
+ } else {
|
|
std::printf("ERR: couldnt send message: %s\n", err.message().c_str());
|
|
std::printf("ERR: couldnt send message: %s\n", err.message().c_str());
|
|
}
|
|
}
|
|
bai::read(socket, recvbuf, bai::transfer_all(), err);
|
|
bai::read(socket, recvbuf, bai::transfer_all(), err);
|
|
- if(err && err != bai::error::eof) {
|
|
|
|
|
|
+ if (err && err != bai::error::eof) {
|
|
std::printf("ERR: couldnt recieve message: %s\n", err.message().c_str());
|
|
std::printf("ERR: couldnt recieve message: %s\n", err.message().c_str());
|
|
- }
|
|
|
|
- else {
|
|
|
|
- std::printf("OK: recieved message %s\n", bai::buffer_cast<const char*>(recvbuf.data()));
|
|
|
|
|
|
+ } else {
|
|
|
|
+ std::printf("OK: recieved message %s\n",
|
|
|
|
+ bai::buffer_cast<const char *>(recvbuf.data()));
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|