Find the answer to your Linux question:
Results 1 to 4 of 4
hi all.. I need to reverse the order of recvfrom() (userspace) command (turning the packet queue to a stack or something like that) meaning: if i'll will sendto("A") sendto("B") sendto("C") ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    2

    Red face finding unix datagram queue in kernel


    hi all..

    I need to reverse the order of recvfrom() (userspace) command (turning the packet queue to a stack or something like that)

    meaning: if i'll will sendto("A") sendto("B") sendto("C")
    and then recvfrom() three times i'll get: C B A.

    (instead of A B C like i would get normally)

    I tried to find the relevant queue but no luck there,
    can anyone please redirect me to it, or give me a hint on how to do it?

    thanks a lot

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    Duh, why? Even if you changed the semantic behavior of the queue to a LIFO queue (Last In, First Out), there is no guarantee that the system hasn't sent "A" before either "B" or "C" is seen in the kernel, etc. There is also no reason why the receiver might not get them in some other order, such as "B", "C", "A" as there is no guarantee of serialization in UDP packets. So, basically what you want to do isn't going to happen, at least with any consistency and reliability. In fact, since there is no guarantee of delivery of UDP packets, the receiver might not even get one or more of the packets. As a result, even with the FIFO queue used today, the recipient might get "C", then "A", and not get "B" at all... Caveat User!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Nov 2009
    Posts
    2
    hi,
    thanks for the answer,

    i know that about UDP. but when we use it on the same host (IPC) recving is most likely to be at the same order of sending.

    anyway, i'm not looking for consistency, it's just a part of a homework assignment.

    and of course, you probably know that but UDP sends packets as they are (wont edit cut and paste the data) so if im doing
    sendto("A"); sendto("B"); sendto("C")
    i think 3 packets will be sent, one for every send (never checked thou).

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    As per the terms of use for these forums, helping people with homework assignments is not allowed. You are going to need to work this out on your own. Good luck.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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