Scroll to navigation

gensio_write(3) Library Functions Manual gensio_write(3)

NAME

gensio_write - Write data to a gensio

SYNOPSIS

#include <gensio/gensio.h>


const void *buf, gensiods buflen,
const char *const *auxdata);

struct gensio_sg {

const void *buf;
gensiods buflen;
};

const struct gensio_sg *sg, gensiods sglen,
const char *const *auxdata);

DESCRIPTION

Write data to the given gensio. The data is in buf and the length of the data is in buflen. Note that gensio_write may not write all of the data given, depending on the gensio type and the internal buffer space. It will return the number of bytes actually written in count which may be NULL if you don't care. (Hint: you should almost always care.)

If gensio_write is unable to write the full amount of data, you should generally buffer the unwritten data and call gensio_set_write_callback_enable(3) to know when you can write the rest of the data. Many applications always buffer the data and enable the write callback to do the write and then disable the write callback when all data is written, for consistency.

gensio_write will never block, if it cannot write all the data it will write what it can and return.

auxdata is used to pass in gensio specific auxiliary data, such as the stream number for SCTP or whether the data is out of band data for SCTP or TCP.

gensio_write_sg is like gensio_write, but it takes a scatter-gather structure to allow you to combine multiple chunks of data without copying. Note that if you get a partial write, you must figure out where the write ended in your scatter-gather list and start the next write from there.

RETURN VALUES

Zero is returned on success, or a gensio error on failure.

SEE ALSO

gensio_err(3), gensio(5)

24 Feb 2019