zeromq windows version

develop
Petr Mrázek 2011-11-25 23:21:31 +01:00
parent 780b659210
commit c0a6036cde
6 changed files with 21 additions and 4 deletions

@ -23,10 +23,20 @@ IF(UNIX)
) )
ENDIF() ENDIF()
ELSE() ELSE()
SET(PROJECT_LIBS
${server_SOURCE_DIR}/zeromq/libzmq.lib
${PROJECT_LIBS}
)
include_directories (
${include_directories}
${server_SOURCE_DIR}/zeromq
)
install(PROGRAMS ${server_SOURCE_DIR}/zeromq/libzmq.dll DESTINATION ".")
ENDIF() ENDIF()
DFHACK_PLUGIN(server ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS}) DFHACK_PLUGIN(server ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS})
add_executable ( helloclient hello.cpp ) add_executable ( helloclient hello.cpp )
target_link_libraries ( helloclient ${server_SOURCE_DIR}/zeromq/libzmq.so.1) target_link_libraries ( helloclient ${PROJECT_LIBS})
install(TARGETS helloclient RUNTIME DESTINATION . ) install(TARGETS helloclient RUNTIME DESTINATION . )

@ -6,14 +6,14 @@
#include <zmq.h> #include <zmq.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> //#include <unistd.h>
int main (void) int main (void)
{ {
void *context = zmq_init (1); void *context = zmq_init (1);
// Socket to talk to server // Socket to talk to server
printf ("Connecting to hello world server\n"); printf ("Connecting to hello world server...\n");
void *requester = zmq_socket (context, ZMQ_REQ); void *requester = zmq_socket (context, ZMQ_REQ);
zmq_connect (requester, "tcp://localhost:5555"); zmq_connect (requester, "tcp://localhost:5555");
@ -23,7 +23,7 @@ int main (void)
zmq_msg_t request; zmq_msg_t request;
zmq_msg_init_size (&request, 5); zmq_msg_init_size (&request, 5);
memcpy (zmq_msg_data (&request), "Hello", 5); memcpy (zmq_msg_data (&request), "Hello", 5);
printf ("Sending Hello %d\n", request_nbr); printf ("Sending Hello %d...\n", request_nbr);
zmq_send (requester, &request, 0); zmq_send (requester, &request, 0);
zmq_msg_close (&request); zmq_msg_close (&request);

@ -3,6 +3,9 @@
#include <dfhack/Export.h> #include <dfhack/Export.h>
#include <dfhack/PluginManager.h> #include <dfhack/PluginManager.h>
#include <zmq.hpp> #include <zmq.hpp>
#ifndef LINUX_BUILD
#include <windows.h>
#endif
using namespace DFHack; using namespace DFHack;
// Here go all the command declarations... // Here go all the command declarations...
@ -64,7 +67,11 @@ DFhackCExport command_result server (Core * c, std::vector <std::string> & param
c->con.print("Received Hello\n"); c->con.print("Received Hello\n");
// Do some 'work' // Do some 'work'
#ifdef LINUX_BUILD
sleep (1); sleep (1);
#else
Sleep(1000);
#endif
// Send reply back to client // Send reply back to client
zmq::message_t reply (5); zmq::message_t reply (5);

Binary file not shown.

Binary file not shown.

Binary file not shown.