udp

package module
v0.0.0-...-37271b9 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 4 Imported by: 0

README

xk6-udp

A k6 extension for sending strings to UDP port

Build

To build a k6 binary with this plugin, first ensure you have the prerequisites:

Then:

  1. Install xk6:
go install github.com/k6io/xk6/cmd/xk6@latest
  1. Build the binary:
xk6 build master \
  --with github.com/amitmankikar/xk6-udp

Example

import udp from 'k6/x/udp';
import { check } from 'k6';

const conn = udp.connect('host:port');

export default function () {
  udp.writeLn(conn, 'Say Hello');
  let res = String.fromCharCode(...udp.read(conn, 1024))
  check (res, {
    'verify ag tag': (res) => res.includes('Hello')
  });
  udp.close(conn);
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type REQ

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

func (*REQ) SetHeader

func (c *REQ) SetHeader(ver uint32, flag uint32, seq uint32)

type UDP

type UDP struct{}

func (*UDP) Close

func (udp *UDP) Close(conn net.Conn) error

func (*UDP) Connect

func (udp *UDP) Connect(addr string) (net.Conn, error)

func (*UDP) Read

func (udp *UDP) Read(conn net.Conn, size int) ([]byte, error)

func (*UDP) ReadPkt

func (udp *UDP) ReadPkt(conn net.Conn, seq int, size int) ([]byte, error)

func (*UDP) Write

func (udp *UDP) Write(conn net.Conn, data []byte) error

func (*UDP) WriteLn

func (udp *UDP) WriteLn(conn net.Conn, data []byte) error

func (*UDP) WritePktEx

func (udp *UDP) WritePktEx(conn net.Conn, ver uint32, flag uint32, seq uint32, key uint64) error

Jump to

Keyboard shortcuts

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