Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Winsock
Message
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01288289
Message ID:
01289240
Views:
16
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@
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform