Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use jansson with non-blocking I/O? #647

Open
milasudril opened this issue Apr 19, 2023 · 1 comment
Open

How to use jansson with non-blocking I/O? #647

milasudril opened this issue Apr 19, 2023 · 1 comment

Comments

@milasudril
Copy link

From the documentation:

json_t *json_loadfd(int input, size_t flags, json_error_t *error)

It is important to note that this function can only succeed on stream file descriptors (such as SOCK_STREAM). Using this function on a non-stream file descriptor will result in undefined behavior. For non-stream file descriptors, see instead json_loadb(). In addition, please note that this function cannot be used on non-blocking file descriptors (such as a non-blocking socket). Using this function on non-blocking file descriptors has a high risk of data loss because it does not support resuming.

So this one is no-go.

json_load_callback_t

On success, the function should write at most buflen bytes to buffer, and return the number of bytes written; a returned value of 0 indicates that no data was produced and that the end of file has been reached. On error, the function should return (size_t)-1 to abort the decoding process.

But I want to keep the context, so this cannot work either.

I guess it is not possible to do this, or is it?

@Zer0-One
Copy link

#410

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants