Data Structure 
Author Message
 Data Structure

VB6 SP5 on Win2000 SP2.  I don't want to reinvent or reengineer
the wheel.  What's a good data structure for parsing an incoming
byte array from a socket?  (The following is from a question I
posted last week in a couple different newsgroups.)

  - The server will return different record types.  Some record
types have multiple variable-length fields.  The largest record
is about 10k.  My DLL has to be able to handle the record being
transmitted all at once or in many "chunks."  The trouble is I
see no way encapsulating this process neatly:
   -- Upon receipt of 300 bytes:
      --- If bytes 1-4 = "A004" and byte 5 is "X" then
          the record length is 300.  Job done.
      --- If bytes 1-4 = "A004" and byte 5 is "Z" then
          record length is 400.  Wait for the rest.
      --- If bytes 1-4 = "A004" and byte 5 is "A" then
          record length is 250.  Indicate error.
      --- If bytes 1-4 = "A004" and byte 5 is "G" then
          bytes 15-17 are the length of the variable field
          beginning at byte 18.  Grab the bytes, convert
          to a number, add to header bytes, and compare
          to 300.
      --- If bytes 1-4 = "9X88" ...

Thanks.

Mark Jerde
Biometrics - www.idtechpartners.com



Fri, 15 Oct 2004 18:35:56 GMT  
 Data Structure

Quote:

> VB6 SP5 on Win2000 SP2.  I don't want to reinvent or reengineer
> the wheel.  What's a good data structure for parsing an incoming
> byte array from a socket?  (The following is from a question I
> posted last week in a couple different newsgroups.)

>   - The server will return different record types.  Some record
> types have multiple variable-length fields.  The largest record
> is about 10k.  My DLL has to be able to handle the record being
> transmitted all at once or in many "chunks."  The trouble is I
> see no way encapsulating this process neatly:
>    -- Upon receipt of 300 bytes:
>       --- If bytes 1-4 = "A004" and byte 5 is "X" then
>           the record length is 300.  Job done.
>       --- If bytes 1-4 = "A004" and byte 5 is "Z" then
>           record length is 400.  Wait for the rest.
>       --- If bytes 1-4 = "A004" and byte 5 is "A" then
>           record length is 250.  Indicate error.
>       --- If bytes 1-4 = "A004" and byte 5 is "G" then
>           bytes 15-17 are the length of the variable field
>           beginning at byte 18.  Grab the bytes, convert
>           to a number, add to header bytes, and compare
>           to 300.
>       --- If bytes 1-4 = "9X88" ...

It might be possible to build a state-machine which could handle this
stuff, no matter where one received chunk ends and the next begins,
but... yuck...  After all, you could also receive one monster chunk
containing many records!

--
Joe Foster <mailto:jlfoster%40znet.com>  Sacrament R2-45 <http://www.xenu.net/>
WARNING: I cannot be held responsible for the above        They're   coming  to
because  my cats have  apparently  learned to type.        take me away, ha ha!



Sat, 16 Oct 2004 09:36:16 GMT  
 Data Structure
Hmm - we have a 'Packet and Content' problem

Packet :  [Header][Length][Data Content][Footer]

Data Content: Use an INI File format if possible

Read the data blindly into a buffer
Then read 'Packets' out of the buffer

What is actually in the packet should be irrelevant at the 'transport
layer'

On Mon, 29 Apr 2002 10:35:56 EDT, Mark Jerde

Quote:

>VB6 SP5 on Win2000 SP2.  I don't want to reinvent or reengineer
>the wheel.  What's a good data structure for parsing an incoming
>byte array from a socket?  (The following is from a question I
>posted last week in a couple different newsgroups.)

>  - The server will return different record types.  Some record
>types have multiple variable-length fields.  The largest record
>is about 10k.  My DLL has to be able to handle the record being
>transmitted all at once or in many "chunks."  The trouble is I
>see no way encapsulating this process neatly:
>   -- Upon receipt of 300 bytes:
>      --- If bytes 1-4 = "A004" and byte 5 is "X" then
>          the record length is 300.  Job done.
>      --- If bytes 1-4 = "A004" and byte 5 is "Z" then
>          record length is 400.  Wait for the rest.
>      --- If bytes 1-4 = "A004" and byte 5 is "A" then
>          record length is 250.  Indicate error.
>      --- If bytes 1-4 = "A004" and byte 5 is "G" then
>          bytes 15-17 are the length of the variable field
>          beginning at byte 18.  Grab the bytes, convert
>          to a number, add to header bytes, and compare
>          to 300.
>      --- If bytes 1-4 = "9X88" ...

>Thanks.

>Mark Jerde
>Biometrics - www.idtechpartners.com



Sat, 16 Oct 2004 15:18:56 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Updating Data in a Self Joined Many-to-Many Data Structure (Previous Post Omitted Text)

2. Copy Data Structures no data DB to DB

3. copy data structure and data

4. Updating Values in a Self-Joined Many-to-Many Data Structure

5. Passing large data structures in recursive functions

6. Create and manage data structures with this ActiveX component

7. Create and manage data structures with this ActiveX component

8. Data Structures Changes?

9. How to get Access 2.0 data structure?

10. New to VB - Data Structure and Import Question

11. Is there Data Structures in VB?

12. Application of data structure

 

 
Powered by phpBB® Forum Software