G
YouTube TikTok Games
Skip to content

How to send a byte array via wangle? #71

Open

Description

@zhenyu-zhou

I have a byte array (actually the raw packet data) and I know its length. However, it may contain '\0' in the middle so that the example code doesn't work for me - such '\0' will be regarded as the end of string and I cannot send the whole array together to the destination.

I'm not quite familiar with Wangle and any idea for how to build a pipeline for my purpose?

Thanks!

P.S.
The pipeline in the sample code is showed below, it works perfect for the printable strings:

auto pipeline = EchoPipeline::create();
pipeline->addBack(AsyncSocketHandler(sock));
pipeline->addBack(
    EventBaseHandler()); // ensure we can write from any thread
pipeline->addBack(LineBasedFrameDecoder(8192, false));
pipeline->addBack(StringCodec());
pipeline->addBack(EchoHandler());

Activity

  1. djwatson commented on Jan 6, 2017

    @djwatson

    You probably want a LengthFieldBasedFrameDecoder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions