xk6-tcp
    Preparing search index...

    Interface WriteOptions

    Configuration options for writing data to a TCP socket.

    // Write base64-encoded data
    socket.write('SGVsbG8gV29ybGQ=', {
    encoding: 'base64',
    tags: { operation: 'send-auth-token' }
    });

    // Write hex-encoded binary data
    socket.write('48656c6c6f', {
    encoding: 'hex',
    tags: { data_type: 'binary' }
    });
    interface WriteOptions {
        encoding?: string;
        tags?: Record<string, string>;
    }
    Index

    Properties

    Properties

    encoding?: string

    The encoding to use when data is a string.

    Supported encodings:

    • 'utf8' (default): Standard UTF-8 text encoding
    • 'ascii': 7-bit ASCII encoding
    • 'base64': Base64-encoded data
    • 'hex': Hexadecimal string representation
    • And other encodings supported by Go's encoding package

    When writing an ArrayBuffer, this option is ignored.

    tags?: Record<string, string>

    Optional key-value pairs for metrics collection and logging. These tags will be attached to write-related metrics for this specific operation.

    Tags specified here will be merged with socket-level and connection-level tags. Operation-level tags take highest priority for duplicate keys.