Go Back   Grim Dawn Forums > Off Topic > Totally Random

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 09-18-2012, 07:39 PM
hooby's Avatar
hooby hooby is offline
Champion
 
Join Date: Sep 2010
Posts: 1,581
Default Does anyone have experience with websocket servers?

Edit: damn, that should read "does anyone have"... can't edit it anymore...
Edit2: thx to the mod whoever corrected it

I'm currently looking into playing around with websockets a bit - I'd like up to create a little setup where a web server (running FreeBSD in this case) can push arbitrary JSON messages onto connected browsers. Obvious test-scenario would be a single-room webchat. Just to start things off.

The server is virtual and running on an ESX - but that doesn't really matter. I got full root access per ssh and can basically install anything I like - just shouldn't expose the system.

There's a lot of options it seems...

node.js
Python
Perl
Java
Ruby
C/C++
-> all of those feature demo implementations and tutorials... I don't really know what I should prefer.

I kind of tend to trying out node.js. How one could ever come up with the idea to use JS server-side still completely boggles my mind. Plus I'm not particularly fond of what JS calls "object orientation"... it's just not proper. On the other hand, I'm more well-versed in JS than the other mentioned languages, so it should be easier to get into.

And node.js seems to perform pretty well in that task, since it's fully concurrent/event-based. It's developers claim it can easily handle 1000+ simultaneous connections on a single machine - which sounds pretty damn nice.

Any recommendations?

Last edited by hooby; 09-18-2012 at 09:04 PM.
Reply With Quote
  #2  
Old 09-18-2012, 11:42 PM
Jyndal's Avatar
Jyndal Jyndal is online now
Supporter
 
Join Date: Jun 2012
Location: Kissimmee, FL
Posts: 173
Default

Uh...the cow goes moo?

I don't know wth you're talking about, but it sure sounds impressive.
__________________
Professional Kitten Stomper.
Reply With Quote
  #3  
Old 09-19-2012, 02:18 PM
jiaco's Avatar
jiaco jiaco is offline
Super Moderator
 
Join Date: Jan 2010
Location: GMT+1
Posts: 1,566
Default

I had never heard of node.js so I went and read a bit. Very interesting. I like that V8 is behind it. But Google also backed GWT. Javascript is a strange language to say the least.

But I would answer your question: Pick the language that you know the best if it is applicable to the question. But remember to pick a simple prototype app to do proof of principle first. In addition, if you never did CGI, do a hello world JSON output script in bash or C to prove apache is configured properly. Nothing worse than debugging your code to find out that the net was borked.

Last edited by jiaco; 09-19-2012 at 02:18 PM. Reason: Edit: Your welcome for the Edit
Reply With Quote
  #4  
Old 09-19-2012, 03:56 PM
hooby's Avatar
hooby hooby is offline
Champion
 
Join Date: Sep 2010
Posts: 1,581
Default

Thanks for the advice, I really appreciate the goodwill - but you can't use node.js with apache anyways. Apache (and Nginx too) is (are) working fully request based - which basically is the exact opposite of doing socket connections.

Well I possibly shouldn't have asked the question in this forum in the first place - but since afaik there are a few people around who code their own games or at least game mods, I thought it doesn't hurt to ask. It totally could have been, that somebody knew something...

Well I guess I'll just give node.js and socket.io a shot. I can still look into something else after it doesn't work out
Reply With Quote
  #5  
Old 10-06-2012, 08:32 AM
asgeirom asgeirom is offline
Initiate
 
Join Date: Oct 2012
Posts: 4
Default

I'm guessing this is what you want:
www w3 org/Protocols/rfc2616/rfc2616-sec8.html#sec8.1
en wikipedia org/wiki/HTTP_persistent_connection

(I'm not allowed to post links, you'll have to fill in the [.] yourself)

With persistent connections the clients won't have to "guess" if they've received messages.

Run time compiled code (js, python, perl) will always use more resources than pre compiled code (java, c/c++). But like jiaco said, prototype first.
Reply With Quote
  #6  
Old 10-06-2012, 09:01 AM
hooby's Avatar
hooby hooby is offline
Champion
 
Join Date: Sep 2010
Posts: 1,581
Default

Thanx alot.

I already have a running testserver (using node.js), using the websocket module (not socket.io yet, and unsure if I want to switch to it).

Chat is fully working, even already added a dice-roller so you can enter Pen&Paper style die-terms (like [2d10+5]) and the server rolls and calculates the result, and a system that allows people to change the color of their nick.

node.js is actually pretty simple and easy to work with, and gives you very quick results.

For anyone interested in stuff like that, I recommend looking into that tutorial:
http://martinsikora.com/nodejs-and-w...-chat-tutorial
That's a very good one (had to search around a bit, to find the kind of tutorial I wanted) - it doesn't use the express framework or any big complex libraries, but really teaches you the basics.

Browser-support for websockets starts to look real good too:
http://caniuse.com/websockets
Once IE10 is released, all major browsers will support websockets (all the others already do so for a while).

Since I don't feel the need to support older browsers, I probably will stick with pure websockets, not using fallbacks to Flash/iFrame/Ajax or anything. It's just not worth the added complexity and overhead.

The only gripe I have, is that I only have a single server to my disposal, and Port 80 on that machine already is used by Apache. The websocket protocoll is designed to use Port 80 too, and upgrade an http-connection to a websocket connection. But that's not possible unless you have one webserver that supports both a the same time.

Since I'm not going to deliver web-pages via node.js, sticking to the proven apache/php/mysql combo, I have to use a different port for websockets, other than 80.

This might lock out people behind stricter firewalls or web-proxies - they might not be able to connect to another port. An upgrade from port 80 on the other hand would work for anyone who is able to surf the web - no matter how walled in.

I'd really like to use Port 80 for websockets, but sadly I can't. I got a suggestion of using 443 for websockets, and 80 for normal webtraffic, but it's kinda ugly to abuse the https port like that, and I'd like to keep the option to add https access later on.
Reply With Quote
  #7  
Old 10-07-2012, 06:30 AM
deathwings51's Avatar
deathwings51 deathwings51 is offline
Advocate
 
Join Date: Jan 2012
Location: India
Posts: 409
Default

http://beej.us/guide/bgnet/

/thread

__________________
Steam profile: http://steamcommunity.com/id/deathwings51

Quote:
The idea is to f**k sh*t up on a level sh*t has not been f***ed before
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:54 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.