Java TCP How do you read a sent stream size (header) and keep reading based upon that size

前端 未结 3 541
悲哀的现实
悲哀的现实 2021-01-29 11:07

Given the following pseudo code. how would I do read in the given data

\"enter

3条回答
  •  囚心锁ツ
    2021-01-29 11:59

    You can try JBBP

    @Bin class Struct { byte [] payload; }
    @Bin class ParsedStream { Struct [] structs; }
    ParsedStream parsed = JBBPParser.prepare("structs[_] { ushort size; byte [size] payload; }").parse(theInStream).mapTo(ParsedStream.class);
    

提交回复
热议问题