socket

package
v0.0.0-...-efbbdf5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 10 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// StatusOK is always set for method calls or events.
	// For replies it indicates successful completion of the method.
	// For streams it indicates confirmation of the end of file on the stream.
	StatusOK = iota

	// StatusError for replies indicates that the method call failed
	// and error information is being returned. For streams this indicates
	// that not all data was sent and the stream has aborted.
	StatusError

	// StatusContinue is only used for streams.
	// This indicates that further data packets will be following.
	StatusContinue
)

request and response statuses

View Source
const (
	// Call is used when making calls to the remote server.
	Call = iota

	// Reply indicates a server reply.
	Reply

	// Message is an asynchronous notification.
	Message

	// Stream represents a stream data packet.
	Stream

	// CallWithFDs is used by a client to indicate the request has
	// arguments with file descriptors.
	CallWithFDs

	// ReplyWithFDs is used by a server to indicate the request has
	// arguments with file descriptors.
	ReplyWithFDs
)

request and response types

View Source
const (
	// B - byte
	B = 1
	// KiB - kibibyte
	KiB = 1024 * B
	// MiB - mebibyte
	MiB = 1024 * KiB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer

type Dialer interface {
	Dial() (net.Conn, error)
}

Dialer is an interface for connecting to libvirt's underlying socket.

type Header struct {
	// Program identifier
	Program uint32

	// Program version
	Version uint32

	// Remote procedure identifier
	Procedure uint32

	// Call type, e.g., Reply
	Type uint32

	// Call serial number
	Serial int32

	// Request status, e.g., StatusOK
	Status uint32
}

Header is a libvirt rpc packet header

type Router

type Router interface {
	Route(*Header, []byte)
}

Router is an interface used to route packets to the appropriate clients.

type Socket

type Socket struct {
	// contains filtered or unexported fields
}

Socket represents a libvirt Socket and its connection state

func New

func New(dialer Dialer, router Router) *Socket

New initializes a new type for managing the Socket.

func (*Socket) Connect

func (s *Socket) Connect() error

Connect uses the dialer provided on creation to establish underlying physical connection to the desired libvirt.

func (*Socket) Disconnect

func (s *Socket) Disconnect() error

Disconnect closes the Socket connection to libvirt and waits for the reader gorouting to shut down.

func (*Socket) Disconnected

func (s *Socket) Disconnected() <-chan struct{}

Disconnected returns a channel that will be closed once the current connection is closed. This can happen due to an explicit call to Disconnect from the client, or due to non-temporary Read or Write errors encountered.

func (*Socket) SendPacket

func (s *Socket) SendPacket(
	serial int32,
	proc uint32,
	program uint32,
	payload []byte,
	typ uint32,
	status uint32,
) error

SendPacket sends a packet to libvirt on the socket connection.

func (*Socket) SendStream

func (s *Socket) SendStream(serial int32, proc uint32, program uint32,
	stream io.Reader, abort chan bool) error

SendStream sends a stream of packets to libvirt on the socket connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL