tcp

package module
v0.0.0-...-4480af1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 2 Imported by: 0

README

xk6-tcp

A k6 extension for sending strings to TCP 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/snormore/xk6-tcp

Example

import tcp from "k6/x/tcp";
import { check } from "k6";

const conn = tcp.connect("host:port");

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCP

type TCP struct{}

func (*TCP) Close

func (tcp *TCP) Close(conn net.Conn) error

func (*TCP) Connect

func (tcp *TCP) Connect(addr string) (net.Conn, error)

func (*TCP) Read

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

func (*TCP) Write

func (tcp *TCP) Write(conn net.Conn, data []byte) error

func (*TCP) WriteLn

func (tcp *TCP) WriteLn(conn net.Conn, data []byte) error

Jump to

Keyboard shortcuts

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