Page 1 of 1

sockets in JS

Posted: Sun Feb 20, 2011 5:49 pm
by Xaleph
Anyone know if there are sockets available in JavaScript? If so, how can we utilize them and if not: what`s a proper alternative?

Re: sockets in JS

Posted: Sun Feb 20, 2011 6:59 pm
by Jackolantern
They are a new feature in HTML5/Javascript 2. It is going to be a while before they are widely usable, since not all major browsers support them, and most of those that do have them deactivated by default for security purposes. Here is W3C's info on it, and here is a tutorial.

Re: sockets in JS

Posted: Sun Feb 20, 2011 7:04 pm
by Xaleph
Aye thanks seems really cool. But like you said, it`s not widely adopted yet, is there an alternative for this? Because a while(true){ listener; } is not going to work right? hmm.. Maybe i should stop using PHP and go overboard to c#..

Re: sockets in JS

Posted: Sun Feb 20, 2011 10:37 pm
by Chris
The only alternative that does work at the moment is comet or reverse-Ajax. A long poling technique.

Re: sockets in JS

Posted: Mon Feb 21, 2011 4:45 am
by Jackolantern
Oh where was that thread posted the other day that had a nice alternative? It is a library that uses WebSockets for those who can use them, and comet for those who cannot. My only concern with that would be if you need to have 2 separate servers set up for them (both WebSockets and Comet need dedicated server applications from what I understand; at least the former does, maybe not Comet).

And I don't know what C# would do unless you plan to use Silverlight (or you are just making desktop apps). Of course, if you do want to come over to the darkside with ASP.NET, I would be happy to have you :twisted: