CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    TCP/IP confusion

    Hello,

    I am using sockets with TCP/IP and the internet address family AF_INET to communicate with a digital oscilloscope. The communication protocol seems a bit confusing since this oscilloscope sends and receives messages using a protocol header. The header is 8 bytes long and the eighth byte is the number of meaningful data in the message.

    Can anyone tell me if this is a standard known protocol header which needs to be handled with the proper settings of the socket, for example the third parameter to the call of socket(...)? Or do you think that this 8-byte header is a device-specific header?

    The header consists of the following bytes:

    Code:
    81 01 01 00 00 00 00 NN
    where NN is the number of meaningful data bytes in the command and response.

    Thanks you.

    Sincerely, Chris.
    You're gonna go blind staring into that box all day.

  2. #2
    Join Date
    Mar 2005
    Posts
    137

    Re: TCP/IP confusion

    This is not a TCP header. This is the application level header beyond TCP/UDP layer. Application follows this format of Type/Length/Value. You can get this info like this

    create a data structure
    Code:
    typedef struct data {
       unsigned long type;
       unsigned long length;
       unsigned char value[255];   /* Max size if data */
    };
    then recv() this data from the Oscilloscope.

    Code:
    data odata; 
    
    int recv_bytes = recv(msocket, (data *)&odata, sizeof(odata),0);
    
    /* take care if endianess below for type and length */
    
    printf("%d ", odata.type); 
    printf("%d ", odata.length);
    for (int i = 0; i < odata.length, i++) {
        printf("0x%X ", odata.value[i]);
    }
    Thanks,

  3. #3
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    Re: TCP/IP confusion

    Thank you nkhambal. Chris.
    You're gonna go blind staring into that box all day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured