What version of node are you running against? I've made a couple comments 
on your code.

As far as message parsing goes you have two routes. Either you can do all 
of it in js, which is fairly standard, or you can write a native module to 
do the same. The later is usually only necessary if the data being parsed 
is packed in some binary format, but in my experience even normal (i.e. 
ascii text) parsing can achieve up to +30% performance gains.

On Friday, June 21, 2013 1:50:10 PM UTC-7, Kaveh Shahbazian wrote:

> Node.JS TCP Server:
>
> server.on('connection', function(sock) {
>
>     sock.setEncoding('ascii');
>

If you're running this on latest master and in a controlled environment 
where you know the input will only be ascii characters then use encoding 
'binary'. You'll get about double the performance since it doesn't take 
time to check if all characters are actually in the ascii range. Though, 
again, this is only for latest master and _only_ if it's a controlled 
environment.

    
>     sock.on('data', function(data) {
> try {
> sock.write(data);
>

Why wrap this in a try/catch?
 

>
> server.on('error', function(err) {
>
});
>

If you're not actively using the callbacks then don't set them. It'll still 
make the event call if a callback is set. Not expensive by any means, but 
also not free.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to