>*----------------------------------------------------------------------------- >*--This gets the data from the socket. It can happen, that the data isn't >*--received in a single rush. Thus we need a EOT (end of transmission) >*--sign to be sure, the data is complete. Until we get this, the data >*--is stuffed into cReceiveBuffer. It is also possible that we could receive >*--more than one transmission at a time, in which case we need to continue *--buffering the transmission until we do receive an EOT marker. >*----------------------------------------------------------------------------- >PROCEDURE DataArrival >* >LPARAMETERS tnByteCount >LOCAL lcBuffer, lnMsgs, i, lcMsgStr, lcThisMsg, lnAtEot, lnEotLen >lcBuffer = SPACE(tnByteCount) >lnEotLen = LEN(EOT) > >=This.GetData( @lcBuffer, , tnByteCount ) > >IF RIGHT(lcBuffer,lnEotLen) <> EOT > This.cReceiveBuffer = This.cReceiveBuffer + lcBuffer >ELSE > *--Add the new buffered into to the existing buffer and quickly clear the > *--existing buffer to accept another transmission. > lcMsgStr = This.cReceiveBuffer + lcBuffer > This.cReceiveBuffer = '' > > *--Find out how many messages were received in this burst. > lnMsgs = OCCURS(EOT, lcBuffer) > > FOR i = 1 TO lnMsgs > lnAtEot = AT(EOT,lcMsgStr) > *--Get the individual msg to process > lcThisMsg = LEFT(lcMsgStr, lnAtEot - 1) > *--Strip the message from the remaining message string > lcMsgStr = SUBSTR(lcMsgStr, lnAtEot + lnEotLen) > > *--External PRG that handles processing all standard client/server msgs > *--The MsgProcessor.prg can be updated without interrupting service. > DO MsgProcessor WITH lcThisMsg, This, This.Parent > NEXT i > > *--Release pgm from the call stack so it gets a fresh copy the next time. > CLEAR PROGRAM > ENDIF > >ENDPROC >>