how to connect to maya's commandport with node webkit?

I'm building a tool to control maya with it and I'm trying to connect to maya's commandport through node webkit to send commands but with no success. I opened the port from maya with mel:

commandPort -n "127.0.0.1:6000";
string $p = `commandPort -q "127.0.0.1:6000"`;
if ($p == 1) {print "CommandPort Opened \n";}
if ($p == 0) {print "CommandPort Closed \n";}

And here is the code inside my html UI:

<script>    
var net = require('net');
var maya = new net.Socket();

maya.connect(6000, '127.0.0.1', function() {
    console.log('Connected');
    maya.write('polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;');
});
</script>

The console in node webkit shows that its connected but nothing happens inside maya.

I just got started with this whole node webkit thing and its pretty cool!!! I need your help to solve this problem.

Thank you all in advanced for any help :)