listenContinuous

listenContinuous(): TcpIpConnection;

The listenContinuous method of the TcpIpConnection class waits for a remote application to connect to its port and returns a reference to the new connection on a new instance of the TcpIpConnection class while the original instance is still available for listening on subsequent calls.

The value of the Connection class state property changes to Connecting (1) when listening is in progress. See also the Connection class timeout property. The newly created instance of the TcpIpConnection class has its state property set to Connected (2) after the successful connection. The following example of the listenContinuous method sets the authentication challenge and verification methods for the connection.

listenContinuous_click(btn: Button input) updating;
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 returned and referenced 
      by TCP.  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 status bar is set to
      read 'connected', and the text boxes filled with the IP address
      and name information. */
    self.tcp.port := 7895;
    self.tcp      := tcp.listenContinuous;
    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;