Closing the link when no longer needed, Socket server command layout – Grass Valley K2 Edge Protocol Manual v1.0 User Manual

Page 8

Advertising
background image

K2 Edge Protocol Manual – document version 1.0 – Page 8

3.7. Closing the link when no longer needed

Remember to close the link with the socket server when communication has finished, using

close(2) on

the socket

fd. Nexos will not close the link; this is the client's responsibility.

Several different approaches exist regarding the lifetime of the client-server link:

1) Open the link, send a command, wait for optional feedback, then close the link. This approach

does not support overlapping commands during communication.

2) Open the link (and keep it open until the client application closes), and perform write() and read()

calls for different commands. This allows for overlapping commands, suitable for clients designed

to send more than a single command.

3.8. Socket server command layout

The nexos socket server only accepts incoming commands that meet specific requirements. The socket

server supports a number of different services, but all of them follow the command layout described next.

An incoming command is only valid when it has the following fields, in given order:

First the lowercase characters '

nex:' (without the quotes).

A space.

A decimal number (in printable ASCII) representing the nexos channel number. First channel is

'0', second is '1', etc.

A space.

A decimal number (in ASCII) representing the nexos render layer, lowest layer is '0'. If not

relevant for the command use '0'.

A space.

The socket server service name (for example

complex).

A space.

Optional additional arguments supported by the given service in ASCII, separated by spaces, no

newlines.

And finally a single newline character (

\n, ASCII LF, 0x0A) to terminate the command.

In pseudo grammar format:

<nex:> <chan> <layer> <service> [arguments] <newline>

A real-world example:

nex: 0 4 complex {cmd=ping;}\n

The terminating newline indicates the "end-of-message". Note that newlines embedded in the command

are not allowed. Also note that it is possible for a remote client to send several commands in one go, each

of them terminated by a newline character.

Advertising