Hi All
I have been through many many tutorial trying to get tcp.scoket listening to a simple chat server.
Ok i have followed the following tutorial and have a simple chat server running on port 8080 http://nowjs.com/doc/example
All i am trying to do is then embed the code below to listen to connections on that port but i am yet to have any success?
var hostname = '127.0.0.1'; //Create a socket and listen for incoming connections var listenSocket = Ti.Network.Socket.createTCP({ host : hostname, port : 8080, accepted : function(e) { // This where you would usually store the newly-connected socket, e.inbound // so it can be used for read / write operations elsewhere in the app. // In this case, we simply send a message then close the socket. Ti.API.info("Listening socket <" + e.socket + "> accepted incoming connection <" + e.inbound + ">"); e.inbound.write(Ti.createBuffer({ value : 'You have been connected to a listening socket.\r\n' })); e.inbound.close(); // close the accepted socket }, error : function(e) { Ti.API.error("Socket <" + e.socket + "> encountered error when listening"); Ti.API.error(" error code <" + e.errorCode + ">"); Ti.API.error(" error description <" + e.error + ">"); } }); // Starts the socket listening for connections, does not accept them listenSocket.listen(); Ti.API.info("Listening now..."); // Tells socket to accept the next inbound connection. listenSocket.accepted gets // called when a connection is accepted via accept() Ti.API.info("Calling accept."); listenSocket.accept({ timeout : 10000 });I am expecting to see the output from the web version in the console of my titanium version.
So if i have my app running in the simulator the web version doesn't work and i need to close the simulator for the web version to start working i have seen the following that is a bit to complex for me to dive straight into i am trying to find a simple example of a chat server with node.js and now.js and working in titanium.
Can someone point me in the right direction thanks
Your Answer
Think you can help? Login to answer this question!