open_port() on FD 0,1 problems

Daniel Goertzen <>
Tue Aug 10 15:39:43 CEST 2010

I am trying to operate an Erlang Port for stdin and stdout
[open_port({fd,0,1}...].  The program below is to receive two integers,
multiply them, and write the result. Every other request vanishes without a
reply, and I don't know why.  Details:

- Windows 7 64 bit.
- Erlang launched with "-noshell -s erlang_rpc_benchmark"
- I have to wait a moment after launching erlang before sending it data, or
I definitely get dataloss.
- Exactly every other packet gets lost, starting with the first one.
- The byte counters on Task Manager show that the request is getting to
erl.exe, but not to my code.
- I've added debug code to verify that there are no other messages appearing
at my receive expression (not currently in code below).
- I wrote a Python version of this program, and it worked without issue.

Background:  I plan to write a Python GUI program with an Erlang child
process.  The test program below is to assess Python->Erlang messaging
performance.  I am open to other IPC approaches if there is something


-export([start/0, std_server/0]).

start() ->
  spawn(fun std_server/0).

std_server() ->
  Port = open_port( {fd,0,1}, [{packet, 4}, binary ] ),

loop(Port) ->
    {Port, { data, <<A:32,B:32>> }} ->
      Result = A*B,
      Port ! {self(), {command, <<Result:32>>}};

More information about the erlang-questions mailing list