server_firstSteps.c 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
  2. * See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
  3. #include <signal.h>
  4. #ifdef UA_NO_AMALGAMATION
  5. #include "ua_types.h"
  6. #include "ua_server.h"
  7. #include "ua_config_standard.h"
  8. #include "ua_network_tcp.h"
  9. #else
  10. #include "open62541.h"
  11. #endif
  12. UA_Boolean running = true;
  13. static void stopHandler(int sig) {
  14. running = false;
  15. }
  16. int main(void) {
  17. signal(SIGINT, stopHandler);
  18. signal(SIGTERM, stopHandler);
  19. UA_ServerConfig config = UA_ServerConfig_standard;
  20. UA_ServerNetworkLayer nl;
  21. nl = UA_ServerNetworkLayerTCP(UA_ConnectionConfig_standard, 16664);
  22. config.networkLayers = &nl;
  23. config.networkLayersSize = 1;
  24. UA_Server *server = UA_Server_new(config);
  25. UA_Server_run(server, &running);
  26. UA_Server_delete(server);
  27. nl.deleteMembers(&nl);
  28. return 0;
  29. }