Thread: How to transmit Data

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    347

    How to transmit Data

    I want to implement a technique where i want to transmit all the data of a structure. The structure as per the requirement it may change as it is used for testing purpose. For example today i may want to transmit data1, data2 to external interface
    Code:
    struct data_tag
    {
    double data1;
    double data2;
    }data;
    tomorrow someone else wants to transmit some other test data he can add another variable where i am not aware of which data type he will use. Another limitation is he can transmit only 8 bytes at a time, next call he has to start from where he stopped. Is it possible to do this? He will use an interface function to transmit data with a pointer to the structure. I am free in choosing the type of structure. please suggest.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,497
    If your users are responsible for serialising and deserialising their own data, then it's easy for you.

    Whether they output
    "data1=1.234, data2=4.567"
    or
    <element name="data1" type="double" value="1.234"/>
    <element name="data2" type="double" value="4.567"/>

    is not your concern.

    All you have to do is achieve a reliable transport.


    > Another limitation is he can transmit only 8 bytes at a time, next call he has to start from where he stopped. Is it possible to do this?
    Yes, it's a loop.

    Code:
    void sendData ( void *addr, size_t len ) {
      // split len up into 8-byte blocks and send them one at a time over your
      // restricted interface.
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-06-2011, 07:43 AM
  2. Replies: 1
    Last Post: 10-04-2010, 10:09 AM
  3. How to transmit a file from Linux to USB drive
    By s1rUK in forum C Programming
    Replies: 2
    Last Post: 06-01-2010, 08:16 AM
  4. Replies: 21
    Last Post: 11-03-2007, 02:56 PM
  5. Replies: 1
    Last Post: 10-22-2005, 05:28 AM

Tags for this Thread