fwrite/format on sockets?

Torbjorn Tornkvist <>
Fri Aug 25 20:56:49 CEST 2000


> It seems like calling fwrite/format on a socket fails with badarg. Is there
> a way to do something like this? 

Use: gen_tcp:send/2 for this.

> If sockets are not IODevices usable by
> fwrite, is there an equiviland to Common Lisp's (format nil "Format
> string")? (Ie return the string which would normally be printed instead of
> printing it).

Use: io_lib:format/2 as shown in the example below:

1> lists:flatten(io_lib:format("hello ~s~n",["world"])).
"hello world\n"

Cheers /Tobbe



More information about the erlang-questions mailing list