======================== 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 for creating an OPC-UA server and/or client. To create a server, start by creating a Lua table with configuration parameters. See the section :ref:`config_table` for additional details. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 4-20 `Full source <_static/server/server_getting_started.lua>`__ An OPC-UA server instance is created by passing the configuration table into the 'newServer' function as shown in the following example: .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 24 `Full source <_static/server/server_getting_started.lua>`__ The Lua function "newServer" returns an OPC-UA server instance. The server instance must first be initialized before it can be started. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 27 `Full source <_static/server/server_getting_started.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: 29-64 `Full source <_static/server/server_getting_started.lua>`__ Starting the Server ------------------- You may connect to the OPC-UA server instance using any OPC-UA client after calling the 'run' method. See the :ref:`Clients_to_Server_Tutorial` for details. .. literalinclude:: examples/server/server_getting_started.lua :language: lua :lines: 67 `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: 70 `Full source <_static/server/server_getting_started.lua>`__