Re: Question about CSocket::Receive()
- From: Fenster <fenster@xxxxxxxxxxxxx>
- Date: Mon, 10 Jul 2006 08:03:08 +0100
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:
Joseph M. Newcomer [MVP]
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.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
--
Fenster
.
- Follow-Ups:
- Re: Question about CSocket::Receive()
- From: Joseph M . Newcomer
- Re: Question about CSocket::Receive()
- References:
- Question about CSocket::Receive()
- From: Fenster
- Re: Question about CSocket::Receive()
- From: Joseph M . Newcomer
- Question about CSocket::Receive()
- Prev by Date: Re: a missing feature in VC debugger
- Next by Date: Re: Question about CSocket::Receive()
- Previous by thread: Re: Question about CSocket::Receive()
- Next by thread: Re: Question about CSocket::Receive()
- Index(es):
Relevant Pages
|