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)); } 
  1. why 2 bytes , how can contain? why taking the fifth byte , multiplying 256? , adding sixth byte?
  2. 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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -