udpclient

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 4 Imported by: 8

README

UDP Client

UDP client for Go

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config Config
}

func New

func New() *Client

func NewWithConfig

func NewWithConfig(config Config) *Client
Example
package main

import (
	"github.com/vikpe/udpclient"
)

func main() {
	config := udpclient.Config{
		BufferSize:  256,
		Retries:     0,
		TimeoutInMs: 800,
	}
	udpClient := udpclient.NewWithConfig(config)
}

func (Client) Request

func (client Client) Request(address string, statusPacket []byte, expectedResponseHeader []byte) ([]byte, error)
Example
package main

import (
	"github.com/vikpe/udpclient"
)

func main() {
	udpClient := udpclient.New()
	statusPacket := []byte{0xff, 0xff, 0xff, 0xff, 's', 't', 'a', 't', 'u', 's', ' ', '2', '3', 0x0a}
	expectedHeader := []byte{0xff, 0xff, 0xff, 0xff, 'n', '\\'}

	response, err := udpClient.Request(
		"qw.foppa.dk:27502",
		statusPacket,
		expectedHeader,
	)
}

type Config

type Config struct {
	BufferSize  uint16
	Retries     uint8
	TimeoutInMs uint16
}

Jump to

Keyboard shortcuts

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