sockets in JS

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

sockets in JS

Post 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?
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: sockets in JS

Post 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.
The indelible lord of tl;dr
Xaleph
Posts: 897
Joined: Mon Feb 07, 2011 2:55 am

Re: sockets in JS

Post 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#..
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: sockets in JS

Post by Chris »

The only alternative that does work at the moment is comet or reverse-Ajax. A long poling technique.
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: sockets in JS

Post 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:
The indelible lord of tl;dr
Post Reply

Return to “Advanced Help and Support”