listen

listen();

The listen method of the TcpIpConnection class waits for a remote application to connect to its port and returns when a connection attempt has been made.

The value of the Connection class state property changes to Connecting (1) when listening is in progress and to Connected (2) when the connection is open.

The code fragment in the following example shows the use of the listen method. This code sets the TCP/IP connection to listen to the current port. If a connection is made, it sets the status bar to read Connected and fills the text boxes with the IP address and name information.

self.tcp.port := 7895;
self.tcp.listen;
if self.tcp.state = Connection.Connected then
    statusLine1.caption := "Connected";
    textBox3.text       := self.tcp.localIpAddress;
    textBox2.text       := self.tcp.remoteIpAddress;
    textBox4.text       := self.tcp.name;
endif;
...

See also the Connection class timeout property.