======================== Server - Getting Started ======================== Creating a Server ----------------- The OPC-UA stack is provided as a Lua module and must be loaded as follows: .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 2 `Full source <_static/server/server_getting_started.lua>`__ The returned value 'ua' is a table with functions that may be used to create an OPC-UA server and client. To create a server you need to call 'ua.newServer' function. The Lua function "newServer" returns an OPC-UA server instance. Before it can be started, the server instance must be initialized. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 4-10 `Full source <_static/server/server_getting_started.lua>`__ It is possible to pass a Lua table with configuration parameters into function 'newServer'. See the section :ref:`config_table` for additional details .. literalinclude:: examples/server/server_auth_anonymous.lua :language: lua :lines: 27-38,42-45 `Full source <_static/server/server_auth_anonymous.lua>`__ Adding Nodes on server ---------------------- Once the server is initialized, you can customize the server by adding new nodes. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 11-45 `Full source <_static/server/server_getting_started.lua>`__ Starting the Server ------------------- After calling the ' run ' method, you may connect to the OPC-UA server instance using any OPC-UA client . See the :ref:`Clients_to_Server_Tutorial` for details. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 47-48 `Full source <_static/server/server_getting_started.lua>`__ Stopping the Server ------------------- The server can be stopped, and the server's listening socket can be closed by calling the 'shutdown' method. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 50-51 `Full source <_static/server/server_getting_started.lua>`__