Back to Adaptive Vision Studio website

You are here: Start » Filter Reference » TCP IP » TcpIp_Accept

TcpIp_Accept


Accepts a connection from a remote client.

Name Type Range Description
inPort Integer 7 - 65535 TCP port to listen on.
inTimeout Integer* 0 - Timeout in milliseconds, block if not specified.
inKeepAliveTime Integer* 2000 - When specified activates Tcp/Ip keep alive on new socket with given idle time.
outSocket SocketId? Connected socket ID.

Description

This filter opens a server socket for listening for and accepting incoming connections, which stays open during the execution of the program.

For every execution this filter will wait for connection from a single client, accept this connection and return a new socket representing connection with the client. The inTimeout input specifies the longest possible waiting time, in milliseconds. When no timeout is specified (set to Auto), the execution is blocking. When filter execution is terminated by timeout condition no socket is returned (Nil is returned on outSocket output) and the operation can be retried later. When timeout is set to zero the filter performs a single check for incoming connection and returns immediately when no connecting clients are available.

Every socket created and returned by this filter must be explicitly closed with TcpIp_Close filter when it is not needed any more.

inKeepAliveTime can be used to enable Keep-Alive mechanism on newly established connection with the client.

Keep-Alive is a mechanism built in the TCP/IP stack, that can be helpful with detecting broken connection in systems with long communication idle periods or with communication in one direction only. When enabled, operating system will send additional control packets to check state of the connection. inKeepAliveTime input specifies the time, in milliseconds, of connection idle state after which connection state will be checked. The exact time after which connection broken state will be detected is system dependent.

The Adaptive Vision Studio or Adaptive Vision Executor process have to have the necessary permissions in local firewall to open a listening port on the executing host. The port is not bound to any specific networking interface or IP address. The port must not be listened to in another process.

This filter can raise IoError when specified port is already in use in local system, or when other unexpected network-related error occurs.

Hints

  • Set inPort to the same port number that the other side of communication will attempt to connect to.
  • Set inTimeout if you want the filter to abort waiting for a connection after a predefined time.

Examples

Description of usage of this filter can be found in examples and tutorial: TcpIp Shoutbox Server.

Remarks

User manual

For more information about using this filter, please follow the link: Using TCP/IP Communication.

Multithreaded environment

This function is not guaranteed to be thread-safe. When used in multithreaded environment, it has to be manually synchronized.

Complexity Level

This filter is available on Basic Complexity Level.

Disabled in Lite Edition

This filter is disabled in Lite Edition. It is available only in full, Adaptive Vision Studio Professional version.

See Also

  • TcpIp_Connect – Connects as a client to a remote TCP server socket.
  • TcpIp_Close – Close a connected TCP socket gracefully.