Re: Question about CSocket::Receive()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



In message <78vsa2pvf963ot399thjp2f485jbl9path@xxxxxxx>, Joseph M. Newcomer <newcomer@xxxxxxxxxxxx> writes
That's your first mistake: you have a class derived from CSocket. This is almost always a
mistake; you should not be using synchronous sockets for any purpose.

Thanks for your kind words. When I wrote my application, my first to use sockets and fairly simple, in the grand scheme of things, I went straight to the documentation where I found mfcsocs.exe, hence the CSocket roots.

Use CAsynchSocket.

I'll give it a spin, thanks.

Note that when you do a Receive, you get some number of bytes. The number of bytes you
receive is unrelated to any number of bytes that have been sent;

I was aware of that.

you are responsible for
doing enough Receive operations to receive all the bytes.

Really? Being responsible for and actually getting all the bytes (for whatever reason) are not the same thing. Hence my question, do I get one stab at Receive() for a particular set of bytes that have "triggered" an OnReceive() or can I get as many as I can handle this time and get the rest later or will they be lost?

It seems, from Scott's post, that I will be able to get them later and that no data should be lost. Whether or not I should be letting the data sit around is another story...

It is your responsibility to
see that you handle concatenating the bytes to form a complete sequence of bytes.

I was aware of that too.

This is
just elementary programming.

It is. Thanks.
joe

On Fri, 7 Jul 2006 16:02:16 +0100, Fenster <fenster@xxxxxxxxxxxxx> wrote:


I have a class derived from CSocket.

I have a vague recollection that I only get one shot at calling
Receive() in my override of OnReceive(). What I mean by that is that if
there's 2k of data to be read but I only read 1k when I call Receive()
then the other 1k gets lost.

Or can I call Receive() more than once within OnReceive() but after I
exit OnReceive() I lose any data that didn't read?

I can't remember where I've read this or something along those lines and
I can't see it in the documentation. It may be that I'm completely
mistaken and it's just my memory playing tricks on me.

Can anyone help me out with this? Thanks.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

--
Fenster
.



Relevant Pages

  • Re: Sold Shaman set... :[
    ... > vanished from your inventory, ... I'm not blaming them because of my mistake. ... I can understand if I sold an apple but it was an armour set I paid 60g. ... realized I lost it I was in an istance. ...
    (alt.games.warcraft)
  • Re: Book Reviewer wanted
    ... I've been lost in my own backyard a few times. ... while skiing, when I didn't know I was lost until I ... A partner of mine made a similar mistake concerning ... in his book Normal Accidents, ...
    (rec.climbing)
  • Re: Did we fight two world wars so that Britain could be destroyed from within?
    ... he doth but mistake the truth totally." ... It left when 'total' lost its adjectival use, ...
    (uk.politics.misc)
  • Re: For those that are a few bricks short and dont understand proper trolling
    ... Nostromo has you pegged right for just a petty little ignoramus. ... Your mistake here invalidates any of your drivel that followed so I snipped it. ... This is dwarfed by the 100s of trillions lost by the entities that were supposed to know which way the economy was headed. ...
    (comp.sys.ibm.pc.games.rpg)