server.c 807 B

12345678910111213141516171819202122232425262728
  1. #include "open62541.h"
  2. #include "open62541-server.h"
  3. #include "open62541-tcp.h"
  4. int main(int argc, char ** argv) {
  5. UA_Server *server;
  6. UA_Server_new(&server);
  7. #define PORT 1234
  8. #define MAX_CONNECTIONS 1024
  9. UA_TcpNetworkLayer_new(&server.configuration.networklayer, PORT, MAX_CONNECTIONS);
  10. UA_Application *application;
  11. UA_Application_new(&application, UA_STRING_STATIC("MyApplication"));
  12. UA_Application_addNamespace(application, 1);
  13. UA_Server_addApplication(server, application);
  14. UA_Int32 myInteger = 0;
  15. UA_NodeId myIntegerNode = {1, UA_NODEIDTYPE_NUMERIC, 50};
  16. UA_Application_addVariableNode(application, &myIntegerNode, UA_INT32, &myInteger);
  17. UA_Server_start(server); // runs a loop until shutdown is triggered
  18. UA_Application_delete(application);
  19. UA_Server_delete(server);
  20. return 0;
  21. }