Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Winsock
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01288289
Message ID:
01289240
Vues:
17
EOT what is it coming from?
I have each scan terminated with chr(13). Can I use it as the end of transmission?

>Hi Mark,
>With TCP, you get a stream. Data doesn't always arrive in the same size in which you sent it, although it will eventually. On one GetData() call you might get "123" and on the next, you might get "CHR(13)5678". What you need to do is build in your own buffering mechanism to deal with this. Something along the lines of this:
>
>
>*-----------------------------------------------------------------------------
>*--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
>
>
>Hope that helps,
>
>-m@
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform