int main (int argc, char ** argv) { printf ("ZEROMQSEND TESTS\n"); printf ("================\n\n"); init (argc, argv); int major, minor, patch; zmq_version (&major, &minor, &patch); printf ("zeromq version is %d.%d.%d\n", major, minor, patch); context = zmq_ctx_new (); // Test notification from plugin test_commit (); // test timeouts test_timeoutConnect (); test_timeoutSubscribe (); print_result ("testmod_zeromqsend"); zmq_ctx_destroy (context); return nbError; }
static int ntop_get_info(lua_State* vm) { char rsp[256]; int major, minor, patch; lua_newtable(vm); lua_push_str_table_entry(vm, "copyright", (char*)"© 1998-2013 - ntop.org"); lua_push_str_table_entry(vm, "authors", (char*)"Luca Deri and Alfredo Cardigliano"); lua_push_str_table_entry(vm, "license", (char*)"GNU GPLv3"); snprintf(rsp, sizeof(rsp), "%s (%s)", PACKAGE_VERSION, NTOPNG_SVN_RELEASE); lua_push_str_table_entry(vm, "version", rsp); lua_push_int_table_entry(vm, "uptime", ntop->getGlobals()->getUptime()); lua_push_str_table_entry(vm, "version.rrd", rrd_strversion()); lua_push_str_table_entry(vm, "version.redis", ntop->getRedis()->getVersion(rsp, sizeof(rsp))); lua_push_str_table_entry(vm, "version.httpd", (char*)mg_version()); lua_push_str_table_entry(vm, "version.luajit", (char*)LUAJIT_VERSION); #ifdef HAVE_GEOIP lua_push_str_table_entry(vm, "version.geoip", (char*)GeoIP_lib_version()); #endif lua_push_str_table_entry(vm, "version.ndpi", ndpi_revision()); zmq_version(&major, &minor, &patch); snprintf(rsp, sizeof(rsp), "%d.%d.%d", major, minor, patch); lua_push_str_table_entry(vm, "version.zmq", rsp); return(CONST_LUA_OK); }
/** * get ZMQ library version */ static void _zmq_version(void) { int major, minor, patch; char verstr[64]; zmq_version (&major, &minor, &patch); sprintf(verstr, "ØMQ version: %d.%d.%d", major, minor, patch); post(verstr); }
int main (void) { int major, minor, patch; zmq_version (&major, &minor, &patch); printf ("Current 0MQ version is %d.%d.%d\n", major, minor, patch); void *context = zmq_ctx_new (); // Socket to talk to clients void *responder = zmq_socket (context, ZMQ_REP); zmq_bind (responder, "tcp://*:5555"); while (1) { // Wait for next request from client char *message = s_recv(responder); printf ("Received %s\n", message); // Do some 'work' sleep (1); // Send reply back to client zmq_msg_t reply; zmq_msg_init_size (&reply, 5); memcpy (zmq_msg_data (&reply), "World", 5); zmq_msg_send (&reply, responder, 0); zmq_msg_close (&reply); } // We never get here but if we did, this would be how we end zmq_close (responder); zmq_ctx_destroy (context); return 0; }
// Report 0MQ version number // static void s_version (void) { int major, minor, patch; zmq_version (&major, &minor, &patch); printf ("Current 0MQ version is %d.%d.%d\n", major, minor, patch); }
int main (int argc, char **argv) { void *argtable[] = { help = arg_lit0("h","help","print this screen"), verbose = arg_lit0("v","verbose","tell me everything"), fsyslog = arg_lit0(NULL,"syslog","use syslog"), cachepath = arg_file1(NULL,NULL,"cachepath","directory or .cdb database file"), netaddress0 = arg_file1(NULL,NULL,"read_address","zmq read network address"), netaddress1 = arg_file1(NULL,NULL,"write_address","zmq write network address"), end = arg_end(20), }; int32_t nerrors = arg_parse(argc,argv,argtable); if (help->count) { fprintf(stdout,"tmpcache %s - version 0\n",__FUNCTION__); arg_print_syntaxv(stdout,argtable,"\n\n"); arg_print_glossary (stdout,argtable,"%-25s %s\n"); goto finish; } if (verbose->count) { fprintf(stdout,"tmpcache host - version 0\n"); int32_t major,minor,patch; zmq_version (&major,&minor,&patch); fprintf(stdout,"compiled with zmq support %d.%d.%d\n",major,minor,patch); goto finish; } if (nerrors) { arg_print_errors (stdout,end,""); arg_print_syntaxv(stdout,argtable,"\n\n"); goto finish; } u_term = 0; signal (SIGINT,signalhandler); signal (SIGTERM,signalhandler); if (fsyslog->count) openlog (NULL,LOG_PID|LOG_NDELAY,LOG_USER); void *read (void *arg) { tc_readconfig_t *config = (tc_readconfig_t *)arg; if (fsyslog->count) syslog (LOG_INFO,"reading cache from %s @ %s",btocstr(config->cachepath),btocstr(config->address)); tc_readfromcache (config); if (fsyslog->count) syslog (LOG_INFO,"closing cache %s @ %s for reading",btocstr(config->cachepath),btocstr(config->address)); }
int main() { int major, minor, patch; zmq_version( &major, &minor, &patch); printf("Current 0MQ version is %d.%d.%d\n", major, minor, patch); return 0; }
int main (int argc, char const *argv[]) { int major, minor, patch; zmq_version(&major, &minor, &patch); printf("Client ZMQ version - %d.%d.%d ", major, minor, patch); void* context = zmq_ctx_new(); void* subscriber = zmq_socket(context, ZMQ_SUB); printf("Collecting stock information from the server.\n"); int conn = zmq_connect(subscriber, "tcp://localhost:4040"); conn = zmq_setsockopt(subscriber, ZMQ_SUBSCRIBE, 0, 0); int i; for(i = 0; i < 10; i++) { zmq_msg_t reply; zmq_msg_init(&reply); zmq_msg_recv(&reply, subscriber, 0); int length = zmq_msg_size(&reply); char* value = malloc(length); memcpy(value, zmq_msg_data(&reply), length); zmq_msg_close(&reply); printf("%s\n", value); free(value); } zmq_close(subscriber); zmq_ctx_destroy(context); return 0; }
// Report 0MQ version number // static void s_version (void) { int major, minor, patch; zmq_version (&major, &minor, &patch); std::cout << "Current 0MQ version is " << major << "." << minor << "." << patch << std::endl; }
int main (void) { int major, minor, patch; zmq_version (&major, &minor, &patch); printf ("Current 0MQ version is %d.%d.%d\n", major, minor, patch); return EXIT_SUCCESS; }
void test() { int major = 0; int minor = 0; int patch = 0; zmq_version(&major, &minor, &patch); std::cout << "Zeromq version = " << major << "." << minor << "." << patch << "\n"; }
/* Version. */ SEXP R_zmq_version(){ int major, minor, patch; zmq_version(&major, &minor, &patch); Rprintf("Current ZeroMQ version is %d.%d.%d\n", major, minor, patch); return(R_NilValue); } /* End of R_zmq_version(). */
void test_version () { int major, minor, patch; zmq_version (&major, &minor, &patch); TEST_ASSERT_EQUAL_INT (ZMQ_VERSION_MAJOR, major); TEST_ASSERT_EQUAL_INT (ZMQ_VERSION_MINOR, minor); TEST_ASSERT_EQUAL_INT (ZMQ_VERSION_PATCH, patch); }
static mrb_value module_version (mrb_state *mrb, mrb_value self) { mrb_value version[3]; int major, minor, patch; zmq_version(&major, &minor, &patch); version[0] = mrb_fixnum_value(major); version[1] = mrb_fixnum_value(minor); version[2] = mrb_fixnum_value(patch); return mrb_ary_new_from_values(mrb, 3, version); }
int main(int argc, char **argv) { zctx_t *ctx; zwssock_t *sock; char *l = argc > 1 ? argv[1] : listen_on; int major, minor, patch; zmq_version (&major, &minor, &patch); printf("built with: ØMQ=%d.%d.%d czmq=%d.%d.%d\n", major, minor, patch, CZMQ_VERSION_MAJOR, CZMQ_VERSION_MINOR,CZMQ_VERSION_PATCH); ctx = zctx_new(); sock = zwssock_new_router(ctx); zwssock_bind(sock, l); zmsg_t* msg; zframe_t *id; while (!zctx_interrupted) { msg = zwssock_recv(sock); if (!msg) break; // first message is the routing id id = zmsg_pop(msg); while (zmsg_size(msg) != 0) { char * str = zmsg_popstr(msg); printf("%s\n", str); free(str); } zmsg_destroy(&msg); msg = zmsg_new(); zmsg_push(msg, id); zmsg_addstr(msg, "hello back"); zwssock_send(sock, &msg); } zwssock_destroy(&sock); zctx_destroy(&ctx); }
static ngx_int_t ngx_zeromq_module_init(ngx_cycle_t *cycle) { int a, b, c; if (zmq_used && !ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) { zmq_version(&a, &b, &c); ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "using ZeroMQ/%d.%d.%d", a, b, c); } return NGX_OK; }
static void s_version_assert (int want_major, int want_minor) { int major, minor, patch; zmq_version (&major, &minor, &patch); if (major < want_major || (major == want_major && minor < want_minor)) { std::cout << "Current 0MQ version is " << major << "." << minor << std::endl; std::cout << "Application needs at least " << want_major << "." << want_minor << " - cannot continue" << std::endl; exit (EXIT_FAILURE); } }
int main (void) { int major, minor, patch; zmq_version (&major, &minor, &patch); assert (major == ZMQ_VERSION_MAJOR && minor == ZMQ_VERSION_MINOR && patch == ZMQ_VERSION_PATCH); assert (zmq_strerror (EINVAL)); return 0; }
static gint lua_zmq_version(lua_State* lua) { gint major; gint minor; gint patch; zmq_version(&major, &minor, &patch); lua_createtable(lua, 3, 0); lua_pushinteger(lua, major); lua_rawseti(lua, -2, 1); lua_pushinteger(lua, minor); lua_rawseti(lua, -2, 2); lua_pushinteger(lua, patch); lua_rawseti(lua, -2, 3); return 1; }
CAMLprim value version_stub () { CAMLparam0 (); CAMLlocal1 (version); int major, minor, patch; zmq_version(&major, &minor, &patch); version = caml_alloc_small(3, 0); Field(version, 0) = Val_int(major); Field(version, 1) = Val_int(minor); Field(version, 2) = Val_int(patch); CAMLreturn (version); }
void zmq_check_version_ok() { int major, minor, patch; zmq_version(&major, &minor, &patch); bool ok = ((major == ZMQ_VERSION_MAJOR) && (minor == ZMQ_VERSION_MINOR) && (patch == ZMQ_VERSION_PATCH)); if (!ok) { std::cerr << "ERROR! 0MQ version we compiled with is " << ZMQ_VERSION_MAJOR << "." << ZMQ_VERSION_MINOR << "." << ZMQ_VERSION_PATCH << " but the version loaded at runtime is " << major << "." << minor << "." << patch << ". These versions should not be different. " << "Please check your LD_LIBRARY_PATH environment variable." << std::endl; exit(EXIT_FAILURE); } }
int main(int argc, char *argv[]) { int major, minor, patch; bidder_show_help = 0; bidder_show_version = 0; bidder_conf_file = NULL; if (cmd_get_options(argc, argv) == -1) exit(-1); if (bidder_show_help == 1) { print_help(); exit(0); } if (bidder_show_version == 1) { printf("bidder version: bidder_mobile/%s\n", BIDDER_VERSION); exit(0); } //g_file_logger = spdlog::rotating_logger_mt("debug", "logs/debugfile", 1048576*500, 3, true); //g_manager_logger = spdlog::rotating_logger_mt("manager", "logs/managerfile", 1048576*500, 3, true); g_file_logger = spdlog::daily_logger_mt("debug", "logs/debugfile", true); g_manager_logger = spdlog::daily_logger_mt("manager", "logs/managerfile", true); #ifdef DEBUG g_manager_logger->info("-------------------------------------DEBUG MODE-------------------------------------"); #else g_manager_logger->info("-------------------------------------RELEASE MODE-------------------------------------"); #endif zmq_version (&major, &minor, &patch); g_manager_logger->info("Current 0MQ version is {0:d}.{1:d}.{2:d}", major, minor, patch); string configFileName(bidder_conf_file == NULL ? "../adManagerConfig.txt" : bidder_conf_file); configureObject configure(configFileName); configure.display(); bidderServ bidder(configure); bidder.run(); return 0; }
static int Lzmq_version(lua_State *L) { int major, minor, patch; zmq_version(&major, &minor, &patch); lua_createtable(L, 3, 0); lua_pushinteger(L, 1); lua_pushinteger(L, major); lua_settable(L, -3); lua_pushinteger(L, 2); lua_pushinteger(L, minor); lua_settable(L, -3); lua_pushinteger(L, 3); lua_pushinteger(L, patch); lua_settable(L, -3); return 1; }
int main (int argc, char *argv[]) { int major, minor, patch; zmq_version (&major, &minor, &patch); std::cout << "当前ZMQ版本号为" << major << "." << minor << "." << patch << std::endl; zmq::context_t context (1); // Socket to talk to server std::cout << "Collecting updates from weather server...\n" << std::endl; zmq::socket_t subscriber (context, ZMQ_SUB); subscriber.connect("tcp://localhost:5556"); // Subscribe to zipcode, default is NYC, 10001 const char *filter = (argc > 1)? argv [1]: "10001"; subscriber.setsockopt(ZMQ_SUBSCRIBE, filter, strlen (filter)); // Process 100 updates while(true) { int zipcode = 0; int temperature = 0; zmq::message_t update; subscriber.recv(&update); std::istringstream iss(static_cast<char*>(update.data())); iss >> zipcode >> temperature; std::cout << "Temperature for zipcode '"<< filter <<"' was "<<(int) (temperature) <<"F" << std::endl; } return 0; }
inline void version (int *major_, int *minor_, int *patch_) { zmq_version (major_, minor_, patch_); }
inline std::tuple<int, int, int> version() { std::tuple<int, int, int> v; zmq_version(&std::get<0>(v), &std::get<1>(v), &std::get<2>(v) ); return v; }
ZMQ_EXPORT void WINAPI mql4zmq_version (int *major, int *minor, int *patch) { zmq_version(major, minor, patch); }
//misc void WINAPI wine_zmq_version(int *major,int*minor,int*patch) { zmq_version(major,minor,patch); }
// libzmq Z K0(version){K mnp=ktn(KI,3); zmq_version(&kI(mnp)[0],&kI(mnp)[1],&kI(mnp)[2]); R mnp;}
uint64_t ZMQ::clock() { #ifdef __APPLE__ return (mach_absolute_time() * s_scaling_factor) / 1000000; #elif defined(_MSC_VER) uint64_t ticks = (uint64_t)GetTickCount(); if (ticks < s_last_ticks) { static Mutex mutex; mutex.lock(); if (ticks < s_last_ticks) { s_last_ticks = ticks; s_wrap_count++; } mutex.unlock(); } ticks += (uint64_t)s_wrap_count * (uint64_t)MAXDWORD; return ticks; #else struct timespec ts; #if defined(CLOCK_MONOTONIC_RAW) if (clock_gettime(CLOCK_MONOTONIC_RAW, &ts) == 0) { #else if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { #endif return (uint64_t)(((uint64_t)ts.tv_sec * 1000) + ((uint64_t)ts.tv_nsec / 1000000)); } struct timeval tv; gettimeofday(&tv, nullptr); return (uint64_t)(((uint64_t)tv.tv_sec * 1000) + ((uint64_t)tv.tv_usec / 1000)); #endif } int64_t HHVM_STATIC_METHOD(ZMQ, clock) { return ZMQ::clock(); } #define PHP_ZMQ_VERSION_LEN 24 String ZMQ::getLibVersion() { char buffer[PHP_ZMQ_VERSION_LEN]; int major = 0, minor = 0, patch = 0; zmq_version(&major, &minor, &patch); int len = snprintf(buffer, PHP_ZMQ_VERSION_LEN - 1, "%d.%d.%d", major, minor, patch); return String(buffer, len, CopyString); } /////////////////////////////////////////////////////////////////////////////// // ZMQContextData /////////////////////////////////////////////////////////////////////////////// ZMQContextData::ZMQContextData(int ioThreads, bool isPersistent, bool isGlobal) : io_threads(ioThreads), is_persistent(isPersistent), is_global(isGlobal), pid(getpid()) { if (is_global) { static std::once_flag flag; static void* globalContext; std::call_once(flag, [&] { globalContext = zmq_init(io_threads); }); z_ctx = globalContext; } else { z_ctx = zmq_init(io_threads); } if (!z_ctx) { throwExceptionClassZMQErr(s_ZMQContextExceptionClass, "Error creating context: {}", errno); } } static tbb::concurrent_unordered_map<int64_t, ZMQContextData*> s_persistent_context_list; ZMQContextData* ZMQContextData::get(int64_t io_threads, bool is_persistent, bool is_global) { if (is_persistent && !is_global) { auto ct = s_persistent_context_list.find(io_threads); if (ct != s_persistent_context_list.end()) { return ct->second; } } auto ctx = new ZMQContextData(io_threads, is_persistent, is_global); if (is_persistent && !is_global) { s_persistent_context_list[io_threads] = ctx; } return ctx; } /////////////////////////////////////////////////////////////////////////////// // ZMQContext /////////////////////////////////////////////////////////////////////////////// void HHVM_METHOD(ZMQContext, __construct, int64_t io_threads, bool is_persistent) { auto cont = Native::data<ZMQContext>(this_); cont->context = ZMQContextData::get(io_threads, is_persistent, false); }