Visual FoxPro
Visual FoxPro
Receive Bytes up to a Delimiter into a BinData
See more Socket/SSL/TLS Examples
Demonstrates Socket.ReceiveUntilByteBd, which reads bytes until a delimiter byte is encountered and appends all bytes up to and including the delimiter to a BinData.
Background. The delimiter is a raw byte value from 0 through 255. This is useful for framing schemes that terminate each message with a known delimiter byte.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loSocket
LOCAL lnBTls
LOCAL lnMaxWaitMs
LOCAL loBd
lnSuccess = 0
loSocket = CreateObject('Chilkat.Socket')
* Connect to the server using TLS.
lnBTls = 1
lnMaxWaitMs = 5000
lnSuccess = loSocket.Connect("example.com",5000,lnBTls,lnMaxWaitMs)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
CANCEL
ENDIF
* Read bytes until the delimiter byte is encountered, appending all bytes up to and including the
* delimiter to a BinData. The delimiter is a raw byte value from 0 through 255 (here the linefeed
* byte, decimal 10).
loBd = CreateObject('Chilkat.BinData')
lnSuccess = loSocket.ReceiveUntilByteBd(10,loBd)
IF (lnSuccess = 0) THEN
? loSocket.LastErrorText
RELEASE loSocket
RELEASE loBd
CANCEL
ENDIF
? "Received " + STR(loBd.NumBytes) + " bytes (including the delimiter)."
RELEASE loSocket
RELEASE loBd