listenContinuousAsynch
listenContinuousAsynch(receiver: Object; msg: String);
The listenContinuousAsynch method of the TcpIpConnection class waits for remote applications to connect to its port and returns immediately.
When a connection attempt has been made by a remote application, the object specified in the receiver parameter is sent the message specified in the msg parameter.
The listenContinuousAsynch method can be called only when the value of the
When this method is called, 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 listenContinuousAsynch method sets the authentication challenge and verification methods for the connection.
listenContAsynch_click(btn: Button input) updating; vars conlog : ConnectionLog; begin self.tcp.genAuthChallengeMethod := "okGenAuthChallenge"; self.tcp.verifyAuthResponseMethod := "okVerifyAuthResponse"; /* Sets the TCP to listen on the current port. When a connection is made, a new instance of TcpIpConnection is created. The original instance remains available for listening on subsequent calls while the new instance maintains the newly made connection. When this connection is made, the ConnectionLog object referenced by conlog is called and told to run the updateListenContinuousCalls method. The new TcpIpConnection instance is passed to this method as a parameter. */ self.tcp.port := 7895; self.tcp.listenContinuousAsynch(conlog, "updateListenContinuousCalls"); if self.tcp.state = Connection.Connected then statusLine1.caption := "Connected"; textBox3.text := self.tcp2.localIpAddress; textBox2.text := self.tcp2.remoteIpAddress; textBox4.text := self.tcp2.name; endif; end;
The user-written callback method specified in the msg parameter is called when the listenContinuousAsynch method receives a connection request.
The callback method must match the signature required by the listenContinuousAsynch method, as follows.
listenContinuousCallback(tcp: TcpIpConnection; newTcp: TcpIpConnection);
The following method is an example of ConnectionLog class callback method for the listenContinuousAsynch method, which updates the number of method invocations recorded for this method.
updateListenContinuousCalls(tcp: TcpIpConnection; newTcp: TcpIpConnection) updating; begin beginTransaction; self.numberOfListenContinuousCalls := self.numberOfListenContinuousCalls + 1; commitTransaction; self.newTcp.readBinaryAsynch(1024, newTcp, "readCallback"); end;
The listenContinuousAsynch method continues accepting new connection requests until the listener TcpIpConnection class instance is closed.
The listenContinuousCallback method is called for every successful connection request.