[erlang-questions] reading zero-terminated strings from a socket
Loïc Hoguin
essen@REDACTED
Sat Sep 15 22:01:04 CEST 2012
* recv(Socket, _, Timeout)
* binary:split(Bin, << 0 >>)
* bufferize and try next: << Acc/binary, Bin/binary >>
You'll most likely want to check your buffer before receiving again in
case you have receiving many strings at once.
On 09/15/2012 09:56 PM, Joel Reymont wrote:
> I need to read zero-terminated strings from a socket.
>
> What is the most efficient way of doing so?
>
> I wish there was a {packet, ...} option for this but, alas, {packet,
> line} only looks for newlines.
>
> Thanks, Joel
>
> --------------------------------------------------------------------------
> - for hire: mac osx device driver ninja, kernel extensions and usb drivers
> ---------------------+------------+---------------------------------------
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
> ---------------------+------------+---------------------------------------
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
--
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu
More information about the erlang-questions
mailing list