Re: Pretending known chardata is an I/O device?
bengt <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <[email protected]> |
Greetings, You might want to start from https://github.com/ebengt/erlang_string_io Only for a string. Best Wishes, bengt > On 13 Jan 2021, at 14:37, Сергей Прохоров <[email protected]> wrote: > > Hi, Yestin, > > I recently implemented (write-only) IO-server in epgsql: > > https://github.com/epgsql/epgsql/pull/248/files#diff-bee3ee44dca8eaa3ab72727b8d11c695f2ae4dcf0a0534fc51323d0aaa1a3a9fR523-R550 <https://github.com/epgsql/epgsql/pull/248/files#diff-bee3ee44dca8eaa3ab72727b8d11c695f2ae4dcf0a0534fc51323d0aaa1a3a9fR523-R550> > > I'd say it's quite easy task to do, the protocol itself is very compact and well documented and it has a complete example: > > https://erlang.org/doc/apps/stdlib/io_protocol.html <https://erlang.org/doc/apps/stdlib/io_protocol.html> > > I think starting normal gen_server that takes your data string in `init/1` or maybe receives it in a separate call would work fine. And you'd need to handle `{io_request, ..}` messages in `handle_info` gen_server callback. > > Regards, > Sergey