aboutsummaryrefslogtreecommitdiff
path: root/src/transmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/transmitter.cpp')
-rw-r--r--src/transmitter.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/transmitter.cpp b/src/transmitter.cpp
index 047d37d..42295bb 100644
--- a/src/transmitter.cpp
+++ b/src/transmitter.cpp
@@ -46,32 +46,14 @@ int main(int argc, char *argv[]) {
addr = reinterpret_cast<struct sockaddr *>(&addr_si);
addr_len = sizeof(addr_si);
- int count = 0;
- uint8_t buffer[1 << 16];
- while (!feof(stdin)) {
- pb::envelope envelope;
-
- uint16_t size;
-
- cin >> size;
- cin.read(reinterpret_cast<char *>(buffer), size);
-
- /*
- bool ok = envelope.ParseFromArray(buffer, size);
- if (!ok) {
- cerr << "bad read" << endl;
- continue;
- }
- */
-
- if (sendto(s, buffer, size, 0, addr, addr_len) == -1) {
+ launch_reader([&](uint16_t size, const uint8_t* data) {
+ if (sendto(s, data, size, 0, addr, addr_len) == -1) {
throw std::runtime_error("sendto failed");
}
- cerr << "count=" << count++ << endl;
- }
-
- cerr << "transmitter exiting" << endl;
+ return true;
+ });
+ cerr << app_name << " exiting" << endl;
google::protobuf::ShutdownProtobufLibrary();