readBinary

readBinary(length: Integer): Binary;

The readBinary method of the Connection class reads binary data from the connection and returns when the number of bytes of data specified in the length parameter have been read or when a block of data is received, depending on the setting of the fillReadBuffer property. This method can be called only when the value of the state property is Connected (2).

Only one synchronous or asynchronous read operation can be performed at one time on a connection. See also the Connection class timeout property.

The following example shows the use of the readBinary method.

openButton_click(btn: Button input) updating;
vars
    pos : Integer;
    bin : Binary;
begin
    if openButton.caption = $X_Open then
        self.connection.name := connectionName.text;
        self.connection.open;
        openButton.caption   := $X_OK;
        listenButton.caption := $X_Close;
    else
        if sendIt.value then
            if loop.value then
                self.multiSend;
            else
                self.connection.writeBinary(input.text.Binary);
            endif;
        elseif receiveIt.value then
            if loop.value then
                self.multiReceive;
            else
                self.connection.fillReadBuffer := false;
                bin := self.connection.readBinary(200);
                sl1.caption := bin.String;
            endif;
        endif;
    endif;
end;