forked from zeromq/cppzmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zeromq#450 from gummif/gfa/build-examples
Problem: Examples are not compiled
- Loading branch information
Showing
6 changed files
with
99 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR) | ||
|
||
project(cppzmq-examples CXX) | ||
|
||
# place binaries and libraries according to GNU standards | ||
|
||
include(GNUInstallDirs) | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) | ||
|
||
find_package(Threads) | ||
|
||
add_executable( | ||
pubsub_multithread_inproc | ||
pubsub_multithread_inproc.cpp | ||
) | ||
target_link_libraries( | ||
pubsub_multithread_inproc | ||
PRIVATE cppzmq ${CMAKE_THREAD_LIBS_INIT} | ||
) | ||
|
||
add_executable( | ||
hello_world | ||
hello_world.cpp | ||
) | ||
target_link_libraries( | ||
hello_world | ||
PRIVATE cppzmq ${CMAKE_THREAD_LIBS_INIT} | ||
) | ||
|
||
add_executable( | ||
multipart_messages | ||
multipart_messages.cpp | ||
) | ||
target_link_libraries( | ||
multipart_messages | ||
PRIVATE cppzmq ${CMAKE_THREAD_LIBS_INIT} | ||
) |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <zmq.hpp> | ||
|
||
int main() | ||
{ | ||
zmq::context_t ctx; | ||
zmq::socket_t sock(ctx, zmq::socket_type::push); | ||
sock.bind("inproc://test"); | ||
sock.send(zmq::str_buffer("Hello, world"), zmq::send_flags::dontwait); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <iostream> | ||
#include <zmq_addon.hpp> | ||
|
||
int main() | ||
{ | ||
zmq::context_t ctx; | ||
zmq::socket_t sock1(ctx, zmq::socket_type::push); | ||
zmq::socket_t sock2(ctx, zmq::socket_type::pull); | ||
sock1.bind("tcp://127.0.0.1:*"); | ||
const std::string last_endpoint = | ||
sock1.get(zmq::sockopt::last_endpoint); | ||
std::cout << "Connecting to " | ||
<< last_endpoint << std::endl; | ||
sock2.connect(last_endpoint); | ||
|
||
std::array<zmq::const_buffer, 2> send_msgs = { | ||
zmq::str_buffer("foo"), | ||
zmq::str_buffer("bar!") | ||
}; | ||
if (!zmq::send_multipart(sock1, send_msgs)) | ||
return 1; | ||
|
||
std::vector<zmq::message_t> recv_msgs; | ||
const auto ret = zmq::recv_multipart( | ||
sock2, std::back_inserter(recv_msgs)); | ||
if (!ret) | ||
return 1; | ||
std::cout << "Got " << *ret | ||
<< " messages" << 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