Enable HTTP and Websocket access to an O2 host.
An simple HTTP server is operated on the given port with support for web sockets. A name is set up with ZeroConf/Bonjour so that the server can be accessed with the url http://<ensname>.local:<port>
, where <ensname>
is the O2 ensemble name and <port>
is the port
parameter passed to this function. If other hosts are also offering an http service, the name may be changed by appending " (2)" etc. The server may also be reached via the host name which may already be published by ZeroConf/Bonjour, or by the IP address, which is necessary for Android devices that do not support .local. names through mDNS.
- Parameters
-
port | The port number for the web server. If 0, then 8080 is used. |
root | The path to the files to be served. E.g. if the file mypage.htm is in path , then the page will be served by a URL like http://o2.local:8080/mypage.htm . path can be a full path or relative path. If relative, it is relative to the current working directory of the current process. |
- Returns
- O2_SUCCESS if successful, O2_NOT_INITIALIZED if O2 is not initialized, or O2_NO_NETWORK if networking is disabled (see o2_network_enable) or no Internet connection was found.