Hi, 

I have a simple client and server using gRPC to exchange information. For 
now, client side transfer big binary data to server by stream. At server 
side, server reads one by one from stream and copy the content to another 
pre-allocated memory to deal with. 
My question is, is there any way to avoid coping data from stream into 
pre-allocated space and use stream data directly in other thread. 

Here is the code snip 
proto:
message my_data{
    sint32 data_len;
    string data;
}

rpc transfer(stream my_data) returns (stream other)

server:
Status  transfer  ServerContext* context,
                   ServerReaderWriter< my_data  ,  other  >* stream
{ 
    my_data d;
    while (stream->Read(&d)) {
        char* p = malloc(d.data_len);
        strncpy(p, d.data.c_str(), d.data_len);
        //add p to list 
    }
    .....
}

is there any way to avoid above strncpy?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/50e0e1c4-fc52-4286-89db-af4ca6e07fedn%40googlegroups.com.

Reply via email to