Erlang socket client

Wed Jun 1 20:55:51 CEST 2005

On Wed, Jun 01, 2005 at 01:53:13PM -0400, tty@REDACTED wrote:
> Thanks,
> > will CRNL terminate each line. Try that in the erlang code
> > as well.
> > 
> >  gen_tcp:send(Fd, "ati\r\n")
> > 
> > 
> That did it. Its still flaky with responses (not flushing the recieve buffer) but I can live with it for now since its meant as a proof of concept demo. 

Yes, and it's always going to be flaky unless you somehow instruct
erlang how/when to deliver data to you.
Erlang cannot know how you want data delivered to you from
the socket unless you tell it.

Thus, the server ships CRNL terminated lines to you, thus you
should pass the option:

gen_tcp:connect(....[{packet, line} ...])

That way, you'll get a line delivered to your process
as soon as a full CRNL terminated line is read by the driver.

Readup in 

# man -a inet

on how erlang socket line mode works


Claes Wikstrom                        -- Caps lock is nowhere and                  -- everything is under control          

More information about the erlang-questions mailing list