joyent/node — Issue #2068: windows node stdin and stdout #2035 reopened
Author: parmy
Created: 2011-11-10 23:58:25+00:00
State: open

I don't have permission to reopen closed issues, I hope I haven't broken etiquette by creating a new issue, as I'm not sure if closed issues are looked at once closed.

Original issue #2035: https://github.com/joyent/node/issues/2065

Anyway thanks for the respoonses.

I can confirm it on Mac it does work. If it would help I can submit my code.

Continuing: I noticed the version of node.js I'm running is 0.5.8. I downloaded the latest version (0.6.0) and tried it on the following setups:

Windows 7 64bit
Windows Vista 64bit
Windows XP 32bit

I got the same error on each machine: node.exe is not a valid Win32 application

I've reverted to version 0.5.8

The link you sent gave me an idea so I created the following two js files:

//hello-world-console.js
console.log('Hello World Console Version');

and

//hello-world-process.js
process.stdout.write('Hello World Process Version');

From a DOS window I tried the following:

node.exe hello-world-console.js > node.log
this worked fine and proved stdout does work on Windowns

node.exe hello-world-process.js > node.log
this also worked

I updated my Java code and tried again on both Mac and Windows, where I'm using stdin and stdout to comms between Java and node:

Mac:
node hello-world-console.js
I get stdout as expected

Mac:
node hello-world-process.js
I get stdout as expected

Mac:
node
I am able to work directly with the node process. For instance sending the node process 1+2, I receive 3 back

Windows:
node.exe hello-world-console.js
node.js:207
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EINVAL
at errnoException (net_uv.js:566:11)
at Socket.write (net_uv.js:389:18)
at Object. (console.js:26:18)
at Object. (C:\Users\parmy\workspace_3.7_x86\RCPNodeEmbedTest\resources\hello-world-console.js:1:71)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array. (module.js:470:10)
at EventEmitter._tickCallback (node.js:199:26)

Windows:
node.exe hello-world-process.js
node.js:207
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: write EINVAL
at errnoException (net_uv.js:566:11)
at Socket.write (net_uv.js:389:18)
at Object. (C:\Users\parmy\workspace_3.7_x86\RCPNodeEmbedTest\resources\hello-world-process.js:1:16)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array. (module.js:470:10)
at EventEmitter._tickCallback (node.js:199:26)

Windows:
node.exe hello-world.js (<-- This file dones not exist)
node.js:207
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'C:\Users\parmy\workspace_3.7_x86\RCPNodeEmbedTest\resources\hello-world.js'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Array. (module.js:470:10)
at EventEmitter._tickCallback (node.js:199:26)

Window:
node.exe
I get no comms from the node process. So for instance sending the node process 1+2, I don't get a response.

Keeping in mind my Java code is identical on Windows and Mac, I'm lost.

I did think this might be due to different versions of node on Windows and Mac, but then stdout does pipe to a log file on Windows from the DOS window.

My current conclusion is:

1 - I can't prove if stdin (sending commands to node.exe) on Windows works.
2 - I can prove stderr in the Java environment works on Windows
3 - I can't prove if stdout (receiving commands from node.exe on Windows) works in the Jave environment
4 - I can prove stdout works from the DOS terminal on Windows
5 - Mac\UNIX everything works just fine

If you think it would help I'm happy to send you the Java project which runs both on Windows and Mac.

As a temporary workaround on Windows:

1 - Launch a node socket server which listens to a particular port.
2 - In Java create a socket client to establish a connection to the server and send data.
3 - The server will process the command and send the response back.

Ideally I'd love to get stdin and stdout working on Windows Java environment, the same way it works on Mac's Java environment.

Any suggestions for moving forward?

Thanks again for your help.

Parmy