[erlang-questions] open_port() on FD 0,1 problems

Hynek Vychodil hynek@REDACTED
Tue Aug 10 16:05:53 CEST 2010


I don't know how on Windows but try -noinput parameter.

On Tue, Aug 10, 2010 at 3:39 PM, Daniel Goertzen
<daniel.goertzen@REDACTED> wrote:
> 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
> better.
>
> Thanks,
> Dan.
>
>
> -module(erlang_rpc_benchmark).
> -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).
>
> loop(Port) ->
>  receive
>    {Port, { data, <<A:32,B:32>> }} ->
>      Result = A*B,
>      Port ! {self(), {command, <<Result:32>>}};
>  end,
>  loop(Port).
>



-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill
your boss.  Be a data hero!
Try GoodData now for free: www.gooddata.com


More information about the erlang-questions mailing list