Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Receive vs ReceiveFrom...

Receive vs ReceiveFrom...

Scheduled Pinned Locked Moved C / C++ / MFC
questionvisual-studiohelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NewHSKid
    wrote on last edited by
    #1

    Hi everyone, I posted this question earlier today but i didn't get a response. I am a mini jam here, so I decided to ask it again. To the people who read my first post, SORRY! I need to look into a UDP buffer but just peek at it. I have read that I can use MSG_PEEK with ReceiveFrom, but can I use it was Receive? I use Receive(,,MSGPEEK) with a TCP implementation and it works perfectly. How would I do this in UDP? Here is what I have;

    unsigned int temp;
    
    int rVal = Receive(&temp, sizeof(temp), MSG_PEEK);
    if(rVal < 0)
    {
       int err = GetLastError();
    }
    
    else
    {
       unsigned int RecvBuf;
       int rVal2 = Receive(&RecvBuf, sizeof(RecvBuf));   //No peek!
       ...
    }
    

    Any help would be appreciated greatly. If you have code that does this, i would also appreciate that too. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

    A 1 Reply Last reply
    0
    • N NewHSKid

      Hi everyone, I posted this question earlier today but i didn't get a response. I am a mini jam here, so I decided to ask it again. To the people who read my first post, SORRY! I need to look into a UDP buffer but just peek at it. I have read that I can use MSG_PEEK with ReceiveFrom, but can I use it was Receive? I use Receive(,,MSGPEEK) with a TCP implementation and it works perfectly. How would I do this in UDP? Here is what I have;

      unsigned int temp;
      
      int rVal = Receive(&temp, sizeof(temp), MSG_PEEK);
      if(rVal < 0)
      {
         int err = GetLastError();
      }
      
      else
      {
         unsigned int RecvBuf;
         int rVal2 = Receive(&RecvBuf, sizeof(RecvBuf));   //No peek!
         ...
      }
      

      Any help would be appreciated greatly. If you have code that does this, i would also appreciate that too. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

      A Offline
      A Offline
      Alexander M
      wrote on last edited by
      #2

      NewHSKid wrote: Just cause I am 15... hmmm... this is a silly slogan, i'm ONLY 17, and i don't use my age for getting pity! use recvfrom for udp, it will return you the peer's address, so you'll know where the data came from! Don't try it, just do it! ;-)

      S 1 Reply Last reply
      0
      • A Alexander M

        NewHSKid wrote: Just cause I am 15... hmmm... this is a silly slogan, i'm ONLY 17, and i don't use my age for getting pity! use recvfrom for udp, it will return you the peer's address, so you'll know where the data came from! Don't try it, just do it! ;-)

        S Offline
        S Offline
        Steve S
        wrote on last edited by
        #3

        No, you don't understand... These days it works in reverse. I'm 41, have a wife, three kids and an ex-wife. I'm the one that needs pity.... :( On the other hand, though, I can often answer questions sensibly in the CP forums, so it ain't all bad... Steve S

        A 1 Reply Last reply
        0
        • S Steve S

          No, you don't understand... These days it works in reverse. I'm 41, have a wife, three kids and an ex-wife. I'm the one that needs pity.... :( On the other hand, though, I can often answer questions sensibly in the CP forums, so it ain't all bad... Steve S

          A Offline
          A Offline
          Alexander M
          wrote on last edited by
          #4

          oh poor steve... it's sooo shattering :( Don't try it, just do it! ;-)

          N 1 Reply Last reply
          0
          • A Alexander M

            oh poor steve... it's sooo shattering :( Don't try it, just do it! ;-)

            N Offline
            N Offline
            NewHSKid
            wrote on last edited by
            #5

            Who said that was put there for pity? That is really in there so that people DON'T talk down to me and like I am an idiot. I don't believe your comment was necessary, considering that it has nothing to do with pity. Thank you for your help though. I appreciate it. Jimmy Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups