Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

LISTEN

Description

The LISTEN command is used to open a TCP port for incoming connections. This allows remote clients to contact am Avisaro Module over TCP/IP. Listen requires two, three or four arguments.

Parameters

The arguments are in the following order:

1. Handle number
This can be any number from 101 to 200. If LISTEN succeeds, that number can be used in subsequent calls to other TCP-related commands.

2. Listen Port
A port number that is armed to satisfy connection requests. Can be any number in the range from 0 to 65535.

3. TX Delay (Optional)
A value in milliseconds that specifies the delay for outgoing packets. This argument is only valid in streaming mode. Packets are kept as long as they're too small or tx delay expires.

4. Wait until connection established (Optional)
If this argument is given, and it is exactly the word "WAIT", the command interface will block until a client has successfully established a connection.

Return Value

ERR_OK (0) if everything works as expected. The socket is then in listen state.
ERR_ARGUMENT (4) if one ore more arguments failed validation.
ERR_NOCONN (38) if, for any reason, the socket could not enter listen state.

Example

LISTEN 101 12345 

Puts socket #101 into listen mode on TCP port 12345. Arguments 3 and 4 are omitted.

Remarks

If the 4.th argument (WAIT) is used and no client connects to the module, the command interface remains frozen until the module restarts or the socket is closed by other means (e.g. over the web interface).