Thread: Combining Data

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Combining Data

    In my program i have a couple of void pointers (pointing to a chunk of data) a few integer variables and so on...

    I need to send all this data(say over the network)..



    for example

    Code:
     
    void *a,*b;
    int c,d,e;
     
    ----
    ----
    ---
    /*something like*/
    send(a+b+c+d+e)
    so i need to send the data together.. how do i clump the data together..

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Put it all into a character buffer and send the buffer. Just make sure you delimit it somehow

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    So what does 1 send call have which 5 send calls doesn't?
    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.

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Quote Originally Posted by Salem
    So what does 1 send call have which 5 send calls doesn't?
    well I have to send this stream of data to the Cisco call manager and the call manager runs its own protocol and each time a stream of data is sent its inepreted as one set of commands.. If i break it down the call manager ignores the messages....

    But i should be able to achieve this by 5 sends if I modify the way send works...
    As Thantos said I did plan to create a temp buffer but I think i will try to modify the send stuff..

    thank you both..

  5. #5
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Well one problem is this: You can never guartnee how much will be sent before you send it. So if the call manager requires everything in one shot then there is something seriously wrong. Granted anything under 1k should be ok but still...

  6. #6
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    the data anyways is still broken into packets before being sent.. so my guess is as Salem pointed out there should be no problem with 5 send calls as long as the data sent... what I think is happening in the send function is adding some extra data at the end which tell the call manager that this particular set is complete.... I think I will try running ethereal and see whats happening..

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    yeah a end of transmission signal would be the most likely course.

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Are you sending data using TCP or UDP ?
    TCP is a stream protocol, so it really doesn't matter how many send calls there are, because you have no control over fragmentation at the lower levels.
    UDP is a datagram protocol, so each send is matched exactly with each receive.
    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.

  9. #9
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    The call manager uses a protocol by name Skinny over TCP... the send function adds the skinny protocol flags and other details before sending the data over TCP.. so my guess is skinny protocol is adding somehting on every send call...

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>my guess is skinny protocol is adding somehting on every send call
    How are you doing the send? Via a standard send() or write() call, or something "skinny specific"?

    If it's of any use (and is available to you), check out the writev() function. It can write multiple buffers to a file stream (socket) in one call, thus reducing the chances of packet fragmentation.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Quote Originally Posted by Hammer
    >>my guess is skinny protocol is adding somehting on every send call
    How are you doing the send? Via a standard send() or write() call, or something "skinny specific"?

    If it's of any use (and is available to you), check out the writev() function. It can write multiple buffers to a file stream (socket) in one call, thus reducing the chances of packet fragmentation.
    thanks I will check it out... I will try to create a stream which can be picked up by the send stuff.. yes its skinny specific...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  2. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  3. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  4. binary tree of processes
    By gregulator in forum C Programming
    Replies: 1
    Last Post: 02-28-2005, 12:59 AM
  5. Replies: 1
    Last Post: 07-31-2002, 11:35 AM