int main () { zmq::context_t context (1); zmq::socket_t socket (context, ZMQ_PUSH); socket.bind ("tcp://*:5556"); int i = 0; char data[1024] = ""; while (true){ memset(data, 0, 1024); snprintf(data,1024, "Pushed data %d", i++); zmq::message_t pushdata (strlen(data) + 1); memcpy((void *)pushdata.data(), data, strlen(data) + 1); socket.send (pushdata); sleep(1); } socket.close(); context.close(); return 0; }
static int Read(lua_State *L) { int type; hostmem_t* hostmem = checkhostmem(L, 1, NULL); size_t offset = luaL_optinteger(L, 2, 0); size_t size = luaL_optinteger(L, 3, hostmem->size - offset); if((offset >= hostmem->size) || (size > hostmem->size - offset)) return luaL_error(L, errstring(ERR_BOUNDARIES)); if(lua_type(L, 4) == LUA_TSTRING) /* unpack according to 'type' */ { type = checktype(L, 4); if(size == 0) { lua_newtable(L); return 1; } return pushdata(L, type, hostmem->ptr + offset, size); } if(size == 0) lua_pushstring(L, ""); else lua_pushlstring(L, hostmem->ptr + offset, size); return 1; }
void StackResolver::processOpCode(const OpCode& oc) { if (oc.opcode_ >= 1 && oc.opcode_ <= 75) { pushdata(oc.dataRef_); return; } if (oc.opcode_ >= 81 && oc.opcode_ <= 96) { unsigned val = oc.opcode_ - 80; push_int(val); return; } opCodeCount_++; switch (oc.opcode_) { case OP_0: pushdata(BinaryData()); break; case OP_PUSHDATA1: case OP_PUSHDATA2: case OP_PUSHDATA4: pushdata(oc.dataRef_); break; case OP_DUP: op_dup(); break; case OP_HASH160: case OP_SHA256: { opHash_ = true; op_1item_verify(oc); break; } case OP_RIPEMD160: case OP_HASH256: op_1item_verify(oc); break; case OP_EQUAL: { if (opCodeCount_ == 2 && opHash_) isP2SH_ = true; op_2items(oc); break; } case OP_CHECKSIG: op_2items(oc); break; case OP_EQUALVERIFY: case OP_CHECKSIGVERIFY: op_2items_verify(oc); break; case OP_CHECKMULTISIG: case OP_CHECKMULTISIGVERIFY: push_op_code(oc); break; default: throw ScriptException("opcode not implemented with reverse stack"); } }
static int Cgetparent (lua_State *L) { /** content.parent */ ExifContent *content = checkcontent(L); pushdata(L, content->parent); return 1; }
static int Lloadbuffer (lua_State *L) { /** loadbuffer(buf) */ size_t length; const char *buffer = luaL_checklstring(L, 1, &length); pushdata(L, exif_data_new_from_data((const unsigned char *)buffer, length)); return 1; }
static int Lloadfile (lua_State *L) { /** loadfile(path) */ const char *path = luaL_checkstring(L, 1); pushdata(L, exif_data_new_from_file(path)); return 1; }
static int Lnew (lua_State *L) { /** new() */ pushdata(L, exif_data_new()); return 1; }