writeBinaryAsynch

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

The writeBinaryAsynch method of the TcpIpConnection 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 Connection class state property is Connected (2). See also the Connection class timeout property.

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 to set the encryptMethod property for the connection.

buttonSendAsynch_click(btn: Button input) updating;
vars
    conlog : ConnectionLog;
begin
    tcp.encryptMethod := "okEncrypt";
        // 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.
        tcp.writeBinaryAsynch(textBox1.text.Binary,c,"updateBinaryWrites");
    endif;
end;

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

writeBinaryCallback(tcp: TcpIpConnection);

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(tcp: TcpIpConnection) updating;
begin
    tcp.readBinaryAsynch(1024, tcp, "readCallback");
end;