c# - SuperSocket ReceiveFilter implementation -
according supersocket documentation, have implement receivefilter receive binary data , convert object application can work it.
currently i'm working client side using supersocket.clientengine. documentation seems fixedheaderreceivefilter - fixed header body length protocol work best me. i'm not quite understanding it's logic.
so uses first 4 bytes request name, , 2 bytes request body length.
/// +-------+---+-------------------------------+ /// |request| l | | /// | name | e | request body | /// | (4) | n | | /// | |(2)| | /// +-------+---+-------------------------------+ protected override int getbodylengthfromheader(byte[] header, int offset, int length) { return (int)header[offset + 4] * 256 + (int)header[offset + 5]; } protected override binaryrequestinfo resolverequestinfo(arraysegment<byte> header, byte[] bodybuffer, int offset, int length) { return new binaryrequestinfo(encoding.utf8.getstring(header.array, header.offset, 4), bodybuffer.clonerange(offset, length)); }
- why 2 bytes , how can contain? why taking the fifth byte , multiplying 256? , adding sixth byte?
- so means server should assemble packet according protocol. how calculate length of body , put header?
my application sends xml request server , retrieves xml response. want able transfer big files on network. please me.
Comments
Post a Comment