writeBinaryAsynch

writeBinaryAsynch(buffer:   Binary:
                  receiver: Object;
                  msg:      String);

The writeBinaryAsynch method of the Connection class writes binary data to the connection and returns immediately. When the operation is complete, the object specified in the receiver parameter is sent the name of the callback method specified in the msg parameter. User-written methods specified in the msg parameter are sent in the order that they are received by the connection object.

Multiple asynchronous write operations can be performed against one connection simultaneously.

The writeBinaryAsynch method can be called only when the value of the state property is Connected (2).

When the write operation has been completed, the user-written callback method specified in the msg parameter is called.

The following example shows the use of the writeBinaryAsynch method.

buttonSendAsynch_click(btn: Button input) updating;
vars
    conlog : ConnectionLog;
begin
    // Sets the conlog variable to reference a ConnectionLog object.
    // If none exists, it is created and its properties initialized.
    if self.connection.state = Connection.Connected then
        beginTransaction;
            conlog := ConnectionLog.firstInstance;
            if conlog = null then
                create conlog;
                conlog.numberOfListenCalls  := 0;
                conlog.numberOfOpenCalls    := 0;
                conlog.numberOfCloseCalls   := 0;
                conlog.numberOfBinaryReads  := 0;
                conlog.numberOfBinaryWrites := 0;
            endif;
        commitTransaction;
        // Outputs the binary data from the text box to the connection
        // and returns immediately.  When the data is written, the
        // ConnectionLog object referenced by conlog is called, and
        // told to run the updateBinaryWrites method.
        self.connection.writeBinaryAsynch(textBox1.text.Binary, conlog,
                                          "updateBinaryWrites");
    endif;
end;

The callback method must match the signature required by the calling writeBinaryAsynch method, as follows.

writeBinaryCallback(connection: Connection);

The following method is an example of a ConnectionLog class callback method for the writeBinaryAsynch method, which updates the number of method invocations recorded for this method.

updateBinaryWrites(connection: Connection) updating;
begin
    beginTransaction;
    self.numberOfBinaryWrites := self.numberOfBinaryWrites + 1;
    commitTransaction;
end;

See also the Connection class timeout property.