-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrated dynamic attacker allocation in code. Tested with static va…
…lues but dynamic values are successfully received
- Loading branch information
1 parent
cf6ae7c
commit 4c6929d
Showing
11 changed files
with
142 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
#include <string> | ||
#include <chrono> | ||
#include <thread> | ||
#include <iostream> | ||
#include <zmq.hpp> | ||
// #include <string> | ||
// #include <chrono> | ||
// #include <thread> | ||
// #include <iostream> | ||
// #include <zmqpp/zmqpp.hpp> | ||
|
||
int main() | ||
{ | ||
using namespace std::chrono_literals; | ||
// int main() | ||
// { | ||
// using namespace std::chrono_literals; | ||
|
||
std::cout << "Starting server..." << std::endl; | ||
// std::cout << "Starting server..." << std::endl; | ||
|
||
// initialize the zmq context with a single IO thread | ||
zmq::context_t context{1}; | ||
// // initialize the zmq context with a single IO thread | ||
// zmqpp::context context; | ||
|
||
// construct a REP (reply) socket and bind to interface | ||
zmq::socket_t socket{context, zmq::socket_type::rep}; | ||
socket.bind("tcp://*:5555"); | ||
// // construct a REP (reply) socket and bind to interface | ||
// zmqpp::socket_t socket{context, zmqpp::socket_type::rep}; | ||
// socket.bind("tcp://*:5555"); | ||
|
||
std::cout << "Server is running on port 5555..." << std::endl; | ||
// std::cout << "Server is running on port 5555..." << std::endl; | ||
|
||
// prepare some static data for responses | ||
const std::string data{"World"}; | ||
// // prepare some static data for responses | ||
// const std::string data{"World"}; | ||
|
||
for (;;) | ||
{ | ||
zmq::message_t request; | ||
// for (;;) | ||
// { | ||
// zmqpp::message_t request; | ||
|
||
std::cout << "Waiting for messages..." << std::endl; | ||
// std::cout << "Waiting for messages..." << std::endl; | ||
|
||
// After (warning fixed): | ||
if (!socket.recv(request, zmq::recv_flags::none)) { | ||
std::cerr << "Failed to receive message" << std::endl; | ||
continue; | ||
} | ||
std::cout << "Received " << request.to_string() << std::endl; | ||
|
||
// simulate work | ||
std::this_thread::sleep_for(1s); | ||
|
||
// send the reply to the client | ||
auto res = socket.send(zmq::buffer(data), zmq::send_flags::none); | ||
if (!res) { | ||
std::cerr << "Failed to send response" << std::endl; | ||
continue; | ||
} | ||
std::cout << "Sent response: " << data << std::endl; | ||
} | ||
|
||
return 0; | ||
} | ||
// // After (warning fixed): | ||
// if (!socket.recv(request, zmqpp::recv_flags::none)) { | ||
// std::cerr << "Failed to receive message" << std::endl; | ||
// continue; | ||
// } | ||
// std::cout << "Received " << request.to_string() << std::endl; | ||
|
||
// // simulate work | ||
// std::this_thread::sleep_for(1s); | ||
|
||
// // send the reply to the client | ||
// auto res = socket.send(zmqpp::buffer(data), zmqpp::send_flags::none); | ||
// if (!res) { | ||
// std::cerr << "Failed to send response" << std::endl; | ||
// continue; | ||
// } | ||
// std::cout << "Sent response: " << data << std::endl; | ||
// } | ||
|
||
// return 0; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters