Dart SecureTcp, SecureServer Controls
Search Method
String, Byte array, or DartStream object. Received bytes are copied into this variable.
String, Byte array, or DartStrings object. If Token is a string or byte array Data captures all bytes up to and including Token. If Token is a DartStrings object, each string is checked and Data is copied when the first match occurs.
Description

Receive data up to and including a terminating sequence. The data stream is searched for the specified Token, and the specified string, byte array, or DartStream object is filled with the data stream up to and including the specified Token.

This method is useful for processing variable-length records or lines that are defined by known delimiter strings.

Syntax
Visual Basic
Public Function Search( _
   ByRef Data As Variant, _
   ByRef Token As Variant _
) As Long
Parameters
Data
String, Byte array, or DartStream object. Received bytes are copied into this variable.
Token
String, Byte array, or DartStrings object. If Token is a string or byte array Data captures all bytes up to and including Token. If Token is a DartStrings object, each string is checked and Data is copied when the first match occurs.
Return Value
The number of Unicode characters or bytes copied into Data.
Remarks

You can use this method only when the State is tcpConnected or tcpClosing; otherwise, a ptNotConnected error is generated. When the State is tcpClosing, use the Receive, Fill, or Search methods to flush the buffer and cause the State to change to tcpClosed.

If the specified Token is found, then the string, byte array, or DartStream object is always resized to the length needed to hold all the data received, up to and including the token. Count returns the length of the string or size of the byte array. When using a DartStream object, Count returns the Size of the DartStream minus the Position of the DartStream when it was passed in. Be aware that if you keep passing a DartStream, it will keep growing in Size. To keep this from happening, the DartStream object Clear method should be used before passing it in. If the specified token is not found, then the string or byte array is not altered in any way, and Count is 0. When Data is a string, all bytes are converted to 16-bit Unicode characters according to the default ANSI code page installed on the system (this is not as efficient as receiving into a Byte array). If the code page is not ASCII, multi-byte characters may convert to single Unicode characters. It is possible that ReceiveBufferCount will indicate that data is available while this method fails to return data because Token is not seen.

Token defines a terminating character sequence. Token must be an initialized string, byte array, or DartStrings object. You may specify Token as a byte array for those environments that do not allow strings with embedded Null characters.

If Timeout is 0, then available data is searched for the terminating Token, and the method immediately returns a Count value of either 0 (Token was not found) or the number of bytes returned. If Timeout is greater than 0, the method blocks and waits for the Token, and no error is generated if the Token arrives within the timeout period. If the timeout period is exceeded, a ptTimeout error is generated, the session is aborted, and all system resources are released.

Blocked returns True while performing a blocking method (Timeout is greater than 0).

Out-of-band data is sent using the Send method with the Urgent parameter set to True. PowerTCP uses the SO_OOBINLINE socket option to always receive out-of-band data "in-line". In other words, all out-of-band data is received as normal data. It is up the user to correctly process this data.

Note: Some environments, such as JavaScript, do not support the passing of parameters by reference. Consequently, such methods as Search cannot be used by passing in a String. You can use the DartStream Object to circumvent this limitation.

Error Codes

This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):

See Also

SecureTcp Object  | SecureTcp Members


PowerTCP SSL for ActiveX Documentation Version 2.2.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic