auto receive(DeserializationManager<ctxs...>* dsm, std::size_t size){ void* recv[] = {alloca(size)}; void** _recv = recv; std::size_t size_buf[] = {size}; raw_receive(1 ,size_buf,_recv); return from_bytes<T>(dsm,(char*) recv[0]); }
void receive(T&... t){ static_assert(forall_nt(std::is_pod<T>::value...), "Error: can't do non-POD right now"); /*std::cout << "yup you called this one" << std::endl; //*/ void* recv[] = {&t...}; std::size_t size_buf[] = {sizeof(T)...}; /*std::cout << "first element in size buf is: " << size_buf[0] << std::endl; //*/ raw_receive(sizeof...(T),size_buf,recv); }
int raw_socket_input(struct pbuf * pbuf, struct nic * nic) { struct socket * sock; struct pbuf * pbuf_new; if ((sock = nic->raw_socket) == NULL) return 0; debug_print("socket num : %ld", get_sock_num(sock)); if (sock->flags & SOCK_FLG_OP_PENDING) { int ret; /* we are resuming a suspended operation */ ret = raw_receive(&sock->mess, pbuf); if (ret > 0) { sock_reply(sock, ret); sock->flags &= ~SOCK_FLG_OP_PENDING; return 0; } else { sock_reply(sock, ret); sock->flags &= ~SOCK_FLG_OP_PENDING; } } /* Do not enqueue more data than allowed */ if (sock->recv_data_size > RAW_BUF_SIZE) { return 0; } /* * nobody is waiting for the data or an error occured above, we enqueue * the packet. We store a copy of this packet */ pbuf_new = pbuf_alloc(PBUF_RAW, pbuf->tot_len, PBUF_RAM); if (pbuf_new == NULL) { debug_print("LWIP : cannot allocated new pbuf\n"); return 0; } if (pbuf_copy(pbuf_new, pbuf) != ERR_OK) { debug_print("LWIP : cannot copy pbuf\n"); return 0; } /* * If we didn't managed to enqueue the packet we report it as not * consumed */ if (sock_enqueue_data(sock, pbuf_new, pbuf_new->tot_len) != OK) { pbuf_free(pbuf_new); } return 0; }
auto receive(DSM* dsm, int size, make_these_ints<T2>... sizes){ static_assert(std::is_base_of<ByteRepresentable, T1>::value && forall_nt(std::is_base_of<ByteRepresentable, T2>::value...), "Error: can't do non-POD right now"); void* recv[] = {alloca(size),alloca(sizes)...}; std::size_t size_buf[] = {size,sizes...}; raw_receive(sizeof...(T2) + 1 ,size_buf,recv); return receive_helper<T1,T2...>(dsm,recv); }
auto receive_data(std::size_t size, void *data){ std::size_t sizes[] = {size}; void* bufs[] = {data}; return raw_receive(1,sizes,bufs); }