I created a simple webserver that is streaming data to any client that connects to it through TCP. I tried to create a Titanium app and run it in the Titanium Mobile Web Previewer, but I keep getting the error: TypeError: Ti.Network.Socket is undefined at /index.html.
var hostname = "127.0.0.1"; var portNr = 1337; var listeningSocket = Ti.Network.Socket.createTCP({ host: hostname, port: portNr, connected: function(e) { Ti.API.error(JSON.stringify(e)); Ti.API.error(JSON.stringify(e.socket)); Ti.API.info('Socket opened!'); }, error: function(e) { Ti.API.error('Error (' + e.errorCode + '): ' + e.error); } }); Ti.API.error("Socket created"); listeningSocket.listen(); Ti.API.error("Now listening on: "+listeningSocket.host+":"+listeningSocket.port); var acceptedParams = { error : function(e) { // Do something with error Ti.API.error("ERROR"); }, timeout: 60000 }; listeningSocket.accept(acceptedParams);It feels like I am missing an import or include somewhere, but I cannot find it. Or maybe I should add a permission, but which one?