O2 2.0
A communication protocol for interactive music and media applications.
Macros | Functions
HTTP/Websockets API

Macros

#define O2_NO_HOSTNAME   "\001"
 

Functions

O2err http_initialize (int port, const char *root)
 Enable HTTP and Websocket access to an O2 host. More...
 

Detailed Description

Function Documentation

◆ http_initialize()

O2err http_initialize ( int  port,
const char *  root 
)

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
portThe port number for the web server. If 0, then 8080 is used.
rootThe 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.