rpc

package module
v0.0.0-...-b99016c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2015 License: MIT Imports: 9 Imported by: 0

README

go-onc-rcp GoDoc

RFC 5530-compatible Golang libraray

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrProgramMismatch   = errors.New("Program Version mismatch")
	ErrProgramUnavilable = errors.New("Program not avilable")
	ErrProcessUnavilable = errors.New("Process not available")
	ErrGarbargeArguments = errors.New("Arguments not interpreted correctly")
	ErrSystemError       = errors.New("Generic system error")
	ErrRPCMismatch       = errors.New("Wrong RPC version")
	ErrAuthError         = errors.New("Authentication error")
	ErrUnknownError      = errors.New("Server returned unknown error")
)
View Source
var (
	ErrTargetSet = errors.New("Reply data destination has already been set")
)

Functions

func IgnoreReply

func IgnoreReply() callModifier

func ToBytes

func ToBytes(array []byte) callModifier

func ToStruct

func ToStruct(data interface{}) callModifier

func WithBytes

func WithBytes(array []byte) callModifier

func WithStruct

func WithStruct(data interface{}) callModifier

Types

type Client

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

func Dial

func Dial(network, address string, prog Program) (*Client, error)

func DialTCP

func DialTCP(address string, prog Program) (*Client, error)

func DialUDP

func DialUDP(address string, prog Program) (*Client, error)

func (*Client) Call

func (c *Client) Call(proc uint32, modifiers ...callModifier) error
Example
package main

import (
	"github.com/JanBerktold/go-onc-rpc"
)

var (
	data      = struct{}{}
	bytearray = make([]byte, 0)
)

func main() {
	client, _ := rpc.DialTCP("localhost:111", rpc.Program{
		Number:  10000,
		Version: 2,
	})
	// do not forget error checking in the real world

	client.Call(4, rpc.NoReply())
	client.Call(4, rpc.ToStruct(&data))
	client.Call(4, rpc.WithBytes([]byte{0x1, 0x2}), rpc.NoReply())
	client.Call(5, rpc.WithStruct(data), rpc.ToBytes(bytearray))

}
Output:

type Handler

type Handler func(io.Writer)

type Program

type Program struct {
	Number  uint32
	Version uint32
}

type Server

type Server struct {
}

Server represents a socket which can host multipli RPC programs

func (*Server) ListenTCP

func (s *Server) ListenTCP(network string, laddr *net.TCPAddr) error

ListenTCP starts the server on the specified TCP address. Method call blocks as long as the server is running.

func (*Server) ListenUDP

func (s *Server) ListenUDP(network string, laddr *net.UDPAddr) error

ListenUDP starts the server on the specified UDP address. Method call blocks as long as the server is running.

func (*Server) Register

func (s *Server) Register(prog Program, handler Handler)

Register is used to make a RPC call available

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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