Search code examples
javascriptajaxcometportsreverse-ajax

port listening in javascript


I'm trying to write some simple chat client in javascript, but I need a way to update messages in real time. While I could use the xmlhttprequest function, I believe it uses up a TCP/IP port on the server and possibly more importantly, is not allowed on my current hosting package. It doesn't seem like an ideal solution anyway as it seems a bit hacky to constantly have an open connection, and it would be a lot easier if I could just listen on the port and take the data as it comes. I looked on the internet and found lots of references to comet and continuous polling, which are unsatisfactory and lots of people say that javascript isn't really suited to it which I can agree with. Now I've actually learned a bit more about how the internet works however, it seems feasible.I don't need to worry about sending messages so far; I can deal with that, but is there any way to listen on a certain port on javascript?


Solution

  • Have you considered perhaps building your app in Flex ? You could make use of Flex's XMLSocket class to implement a low-latency chat client - pretty much the sort of thing it was designed to do