restServerCreate (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

ALL

Firmware version:

2.10.00


This function will create a new REST server.

To free the server again, call restServerFree.

A maximum of two servers can be created at the same time.

 

Input:

port : DINT

The port to listen on.

 

iface : SINT (default 0)

The network interface to listen on. 0 = Any network, 1 = Mobile network, 2 = LAN network, etc. (See Network).

When listening to the WLAN interface, it may be necessary to wait until the network is connected before starting the server with restServerStart.

 

cert : STRING

The name of the server certificate to use with TLS. Leave empty to not use TLS.

See Certificates for more details about how to work with the certificates.

 

key : STRING

Private key for server certificate. Leave empty if not used or if it is included in the server certificate.

 

key_pass : STRING

Password for the private key.

 

accept_ca: STRING

The name of a root certificate. If it is specified, the clients are asked to provide a client certificate signed by it. The client certificate will be made available as part of the request, see restReqClientCertPresent.

 

Output:

handle : SYSHANDLE

A handle to the server.

 

 

Returns: INT

1


- Success

0


- Not supported

-2


- No more servers can be created before one is freed.

-3


- Failed to create server.

-6


- Can not read certificate or key.

 

Declaration:

FUNCTION restServerCreate : INT;
VAR_INPUT
  handle    : ACCESS SYSHANDLE;
  port      : DINT;
  iface     : SINT;
  cert      : STRING;
  key       : STRING;
  accept_ca : STRING;
  key_pass  : STRING;
END_VAR;

 

 

Example:

Please see the "Examples - REST Example"