[erlang-questions] Best way to interface Erlang with Java code

Garry Hodgson <>
Thu Dec 10 21:48:02 CET 2009


zabrane Mikael wrote:

> loop(Port, <<>>).
> 
> and collecte what the "Java" program send back (I'm expecting the same
> "Hello World"):
> 
> loop(Port, Bin) ->
> receive
> {Port, {data, Bin}} ->
>  loop(Port, [Bin | Data]);
> {Port, {exit_status, Status}} ->
>        {exit_status, Status, list_to_binary([lists:reverse(Data)])};
> Any ->
> {error, Any}
> end.

you should fix your loop call, as well.
note that when you first call it, you're passing it a binary.
then, your receive call pattern matches on that same binary.
then you call it recursively, passing it a list of binaries.

problem there.


-- 
Garry Hodgson
Lead Member of Technical Staff
AT&T Chief Security Office (CSO)

"This e-mail and any files transmitted with it are AT&T property, are 
confidential, and are intended solely for the use of the individual or 
entity to whom this e-mail is addressed. If you are not one of the named 
recipient(s) or otherwise have reason to believe that you have received 
this message in error, please notify the sender and delete this message 
immediately from your computer. Any other use, retention, dissemination, 
forwarding, printing, or copying of this e-mail is strictly prohibited."


More information about the erlang-questions mailing list