File: tutorial_server_reverseconnect.c

package info (click to toggle)
open62541 1.4.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 129,032 kB
  • sloc: xml: 1,678,567; cs: 229,004; ansic: 195,263; python: 4,888; sh: 1,456; cpp: 355; makefile: 30
file content (25 lines) | stat: -rw-r--r-- 938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
 * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */

#include <open62541/plugin/log_stdout.h>
#include <open62541/server.h>

static void reverseConnectStateCallback(UA_Server *server, UA_UInt64 handle,
                                        UA_SecureChannelState state, void *context) {
    UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND,
                "Reverse connect state callback for %lu with context %p: State %d",
                (unsigned long)handle, context,  state);
}


int main(void) {
    UA_Server *server = UA_Server_new();

    UA_UInt64 handle = 0;
    UA_Server_addReverseConnect(server, UA_STRING("opc.tcp://localhost:4841"),
                                reverseConnectStateCallback, (void *)123456, &handle);

    UA_Server_runUntilInterrupt(server);
    UA_Server_delete(server);
    return 0;
}