Back to Adaptive Vision Library website

You are here: Start » Function Reference » System » TCP IP » TcpIp_Accept

TcpIp_Accept


Header: STD.h
Namespace: avl
Module: FoundationLite

Accepts a connection from a remote client.

Syntax

void avl::TcpIp_Accept
(
	TcpIpAcceptState& ioState,
	int inPort,
	const atl::Optional<int>& inTimeout,
	const atl::Optional<int>& inKeepAliveTime,
	bool inNoSendDelay,
	atl::Conditional<avl::SocketId>& outSocket
)

Parameters

Name Type Range Default Description
ioState TcpIpAcceptState& Object used to maintain state of the function.
inPort int 7 - 65535 12345 TCP port to listen on.
inTimeout const Optional<int>& 0 - NIL Timeout in milliseconds, block if not specified.
inKeepAliveTime const Optional<int>& 2000 - NIL When specified activates Tcp/Ip keep alive on new socket with given idle time.
inNoSendDelay bool False Disables the Nagle algorithm for the newly connected socket to send the outgoing packets without a delay.
outSocket Conditional<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.

See Also

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