Class Libvirt::Stream
In: ext/libvirt/_libvirt.c
Parent: Object

Methods

Constants

NONBLOCK = INT2NUM(VIR_STREAM_NONBLOCK)
EVENT_READABLE = INT2NUM(VIR_STREAM_EVENT_READABLE)
EVENT_WRITABLE = INT2NUM(VIR_STREAM_EVENT_WRITABLE)
EVENT_ERROR = INT2NUM(VIR_STREAM_EVENT_ERROR)
EVENT_HANGUP = INT2NUM(VIR_STREAM_EVENT_HANGUP)

Attributes

connection  [R] 

Public Instance methods

Call virStreamAbort to abort this stream. Abort is typically used when something on the stream has failed, and the stream needs to be cleaned up.

[Source]

/*
 * call-seq:
 *   stream.abort -> nil
 *
 * Call +virStreamAbort+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamAbort]
 * to abort this stream.  Abort is typically used when something on the stream
 * has failed, and the stream needs to be cleaned up.
 */
static VALUE libvirt_stream_abort(VALUE s) {

Call virStreamEventAddCallback to register a callback to be notified when a stream becomes readable or writeable. The events parameter is an integer representing the events the user is interested in; it should be one or more of EVENT_READABLE, EVENT_WRITABLE, EVENT_ERROR, and EVENT_HANGUP, ORed together. The callback can either be a Symbol (that is the name of a method to callback) or a Proc. The callback should accept 3 parameters: a pointer to the Stream object itself, the integer that represents the events that actually occurred, and an opaque pointer that was (optionally) passed into stream.event_add_callback to begin with.

[Source]

/*
 * call-seq:
 *   stream.event_add_callback(events, callback, opaque=nil) -> nil
 *
 * Call +virStreamEventAddCallback+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamEventAddCallback]
 * to register a callback to be notified when a stream becomes readable or
 * writeable.  The events parameter is an integer representing the events the
 * user is interested in; it should be one or more of EVENT_READABLE,
 * EVENT_WRITABLE, EVENT_ERROR, and EVENT_HANGUP, ORed together.  The callback
 * can either be a Symbol (that is the name of a method to callback) or a Proc.
 * The callback should accept 3 parameters: a pointer to the Stream object
 * itself, the integer that represents the events that actually occurred, and
 * an opaque pointer that was (optionally) passed into
 * stream.event_add_callback to begin with.
 */
static VALUE libvirt_stream_event_add_callback(int argc, VALUE *argv, VALUE s) {

Call virStreamEventRemoveCallback to remove the event callback currently registered to this stream.

[Source]

/*
 * call-seq:
 *   stream.event_remove_callback -> nil
 *
 * Call +virStreamEventRemoveCallback+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamEventRemoveCallback]
 * to remove the event callback currently registered to this stream.
 */
static VALUE libvirt_stream_event_remove_callback(VALUE s) {

Call virStreamEventUpdateCallback to change the events that the event callback is looking for. The events parameter is an integer representing the events the user is interested in; it should be one or more of EVENT_READABLE, EVENT_WRITABLE, EVENT_ERROR, and EVENT_HANGUP, ORed together.

[Source]

/*
 * call-seq:
 *   stream.event_update_callback(events) -> nil
 *
 * Call +virStreamEventUpdateCallback+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamEventUpdateCallback]
 * to change the events that the event callback is looking for.  The events
 * parameter is an integer representing the events the user is interested in;
 * it should be one or more of EVENT_READABLE, EVENT_WRITABLE, EVENT_ERROR,
 * and EVENT_HANGUP, ORed together.
 */
static VALUE libvirt_stream_event_update_callback(VALUE s, VALUE events) {

Call virStreamFinish to finish this stream. Finish is typically used when the stream is no longer needed and needs to be cleaned up.

[Source]

/*
 * call-seq:
 *   stream.finish -> nil
 *
 * Call +virStreamFinish+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamFinish]
 * to finish this stream.  Finish is typically used when the stream is no
 * longer needed and needs to be cleaned up.
 */
static VALUE libvirt_stream_finish(VALUE s) {

Call virStreamFree to free this stream. The object will no longer be valid after this call.

[Source]

/*
 * call-seq:
 *   stream.free -> nil
 *
 * Call +virStreamFree+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamFree]
 * to free this stream.  The object will no longer be valid after this call.
 */
static VALUE libvirt_stream_free(VALUE s) {

Call virStreamRecv to receive up to bytes amount of data from the stream. The return is an array with two elements; the return code from the virStreamRecv call and the data (as a String) read from the stream. If an error occurred, the return_value is set to -1. If there is no data pending and the stream is marked as non-blocking, return_value is set to -2.

[Source]

/*
 * call-seq:
 *   stream.recv(bytes) -> [return_value, data]
 *
 * Call +virStreamRecv+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamRecv]
 * to receive up to bytes amount of data from the stream.  The return is an
 * array with two elements; the return code from the virStreamRecv call and
 * the data (as a String) read from the stream.  If an error occurred, the
 * return_value is set to -1.  If there is no data pending and the stream is
 * marked as non-blocking, return_value is set to -2.
 */
static VALUE libvirt_stream_recv(VALUE s, VALUE bytes) {

Call virStreamRecvAll to receive the entire data stream. The receive block is required and is called one or more times to receive data. Each invocation of the receive block yields the data received and the opaque data passed into the initial call. The block should return -1 if an error occurred and 0 otherwise.

[Source]

/*
 * call-seq:
 *   stream.recvall(opaque){|data, opaque| receive block} -> nil
 *
 * Call +virStreamRecvAll+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamRecvAll]
 * to receive the entire data stream.  The receive block is required and is
 * called one or more times to receive data.  Each invocation of the receive
 * block yields the data received and the opaque data passed into the initial
 * call.  The block should return -1 if an error occurred and 0 otherwise.
 */
static VALUE libvirt_stream_recvall(int argc, VALUE *argv, VALUE s) {

Call virStreamSend to send the data in buffer out to the stream. The return value is the number of bytes sent, which may be less than the size of the buffer. If an error occurred, -1 is returned. If the transmit buffers are full and the stream is marked non-blocking, returns -2.

[Source]

/*
 * call-seq:
 *   stream.send(buffer) -> Fixnum
 *
 * Call +virStreamSend+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamSend]
 * to send the data in buffer out to the stream.  The return value is the
 * number of bytes sent, which may be less than the size of the buffer.  If
 * an error occurred, -1 is returned.  If the transmit buffers are full and the
 * stream is marked non-blocking, returns -2.
 */
static VALUE libvirt_stream_send(VALUE s, VALUE buffer) {

Call virStreamSendAll to send the entire data stream. The send block is required and is executed one or more times to send data. Each invocation of the send block yields the opaque data passed into the initial call and the number of bytes this iteration is prepared to handle. The send block should return an array of 2 elements; the first element should be the return code from the block (-1 for error, 0 otherwise), and the second element should be the data that the block prepared to send.

[Source]

/*
 * call-seq:
 *   stream.sendall(opaque=nil){|opaque, nbytes| send block} -> nil
 *
 * Call +virStreamSendAll+[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamSendAll]
 * to send the entire data stream.  The send block is required and is executed
 * one or more times to send data.  Each invocation of the send block yields
 * the opaque data passed into the initial call and the number of bytes this
 * iteration is prepared to handle.  The send block should return an array of
 * 2 elements; the first element should be the return code from the block
 * (-1 for error, 0 otherwise), and the second element should be the data
 * that the block prepared to send.
 */
static VALUE libvirt_stream_sendall(int argc, VALUE *argv, VALUE s) {

[Validate]