Re: Problems with CAsyncSocket.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"AliR" <AliR@xxxxxxxxxxxxx> wrote in message
news:442af4df$0$3334$a8266bb1@xxxxxxxxxxxxxxxxxxxxxx
You will have to put your Receive calls in a loop. Each call to Receive
can give you a portion of what's available, so you will have to keep
calling
receive until it returns a 0 (meaning there is nothing left).

AliR.


For asynchronous sockets like CAsyncSocket, don't call Receive() more than
once in OnReceive(). The winsock message paradigm is designed so that it
expects you to call Receive() exactly once inside OnReceive(), and no more.
If winsock has more data for your application after the single call to
Receive(), then it will issue another FD_READ which in turn triggers another
call to OnReceive().

See http://support.microsoft.com/kb/185728/EN-US/

Combined with the answers given below by Josh McFarlane, the OP should now
understand that TCP is a stream-based protocol that has no knowledge of the
packets (or chunks or messages) in which the data is sent to the receipient.
This usually means that the sender and receiver must agree on some sort of a
protocol for sending data and deciphering received data. One of the
simplest protocols is to pre-pend each message with the length of the
message before it's sent. On receipt, the recipient waits until it has
received the specified number of bytes before it processes the data, and
saves any residual data it has already received from the beginning of a next
message.

See this too: "How to Use TCP Effectively" at
http://tangentsoft.net/wskfaq/articles/effective-tcp.html

Mike


.



Relevant Pages

  • Re: Processs PreciseMail AntiSpam Gateway - any experience so far ?
    ... > Ok I've now read the latest version of your protocol. ... the whether the mail is delivered in the hands of the receiving ESP. ... > connection from the receiver to the sender adds nothing to this. ...
    (comp.os.vms)
  • Re: Processs PreciseMail AntiSpam Gateway - any experience so far ?
    ... >> Ok I've now read the latest version of your protocol. ... >> connection from the receiver to the sender adds nothing to this. ... The sender "central mailhub" may have one port opened for listening - but since ... Please tell me where the extra control for the receiver from this second ...
    (comp.os.vms)
  • Re: Processs PreciseMail AntiSpam Gateway - any experience so far ?
    ... But the key phrase here is "The receiver CAN". ... In my model, the priority would not ... > you don't need any new protocol to stop spam - a very simple mail filter will ... > Not every organisation has a single central mailhub. ...
    (comp.os.vms)
  • Re: [Full-Disclosure] [LONG] Improving E-mail security...
    ... > line and if it is same than the receiver address ie. 'someone@someone.com' ... Sort of like a required, server based, pgp check? ... Then as the years went on, the protocol became inadequate. ... semi-factual babbling), so I'd need a good group. ...
    (Full-Disclosure)
  • Re: Processs PreciseMail AntiSpam Gateway - any experience so far ?
    ... >>allow end receivers to charge a fee for questionable email. ... If the meta data doesn't pass muster, the receiver leaves the ... > Please tell me where the extra control for the receiver from this second ... A one phase protocol requires a continuous ...
    (comp.os.vms)