openAsynch
openAsynch(receiver: Object; msg: String);
The openAsynch method of the TcpIpConnection class establishes a connection to a remote application and returns immediately. When the connection is established, the object specified in the receiver parameter is sent the message specified in the msg parameter.
Use the
Use the port property to define the target service port when using the open or openAsynch method or to define the listen port when using the listen or listenAsynch method.
The openAsynch method can be called only when the value of the
On asynchronous calls, the state may not change immediately and it may remain Disconnected (0) for a short period until JADE has rescheduled the request.
The following example of the openAsynch method sets the authentication response for the connection.
buttonOpenAsynch_click(btn: Button input) updating; vars conlog : ConnectionLog; begin self.tcp.genAuthResponseMethod := "okGenAuthResponse"; // Attempts to connect to the current port and returns immediately. // If a connection is made, the ConnectionLog object referenced by // conlog is called and told to run the updateOpenCalls method. self.tcp.openAsynch(conlog, "updateOpenCalls"); end;
When the openAsynch method establishes a connection, the user-written callback method specified in the msg parameter is called. The callback method must match the signature required by the calling openAsynch method, as follows.
openCallback(tcp: TcpIpConnection);
The following method is an example of ConnectionLog class callback method for the openAsynch method, which updates the number of method invocations recorded for this method.
updateOpenCalls(tcp: TcpIpConnection) updating; begin beginTransaction; self.numberOfOpenCalls := self.numberOfOpenCalls + 1; commitTransaction; self.tcp.readBinaryAsynch(1024, tcp, "readCallback"); end;