温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/TLSSocket/write
点击访问原文链接

TLSSocket.write method | Bun module | Bun

TLSSocket.write method | Bun module | BunBuildDocsReferenceGuidesBlogDiscord/Bun/TLSSocket/writeMwrite

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/TLSSocket/writeMwrite

method

TLSSocket.writewrite(data: string | BufferSource,byteOffset?: number,byteLength?: number): number;

Writes data to the socket. This method is unbuffered and non-blocking. This uses the sendto(2) syscall internally.

For optimal performance with multiple small writes, consider batching multiple writes together into a single socket.write() call.

@param data

The data to write. Can be a string (encoded as UTF-8), ArrayBuffer, TypedArray, or DataView.

@param byteOffset

The offset in bytes within the buffer to start writing from. Defaults to 0. Ignored for strings.

@param byteLength

The number of bytes to write from the buffer. Defaults to the remaining length of the buffer from the offset. Ignored for strings.

@returns

The number of bytes written. Returns -1 if the socket is closed or shutting down. Can return less than the input size if the socket's buffer is full (backpressure).

// Send a string
const bytesWritten = socket.write("Hello, world!\n");

// Send binary data
const buffer = new Uint8Array([0x01, 0x02, 0x03]);
socket.write(buffer);

// Send part of a buffer
const largeBuffer = new Uint8Array(1024);
// ... fill largeBuffer ...
socket.write(largeBuffer, 100, 50); // Write 50 bytes starting from index 100
Referenced typestype BufferSource = NodeJS.TypedArrayArrayBufferLike> | DataViewArrayBufferLike> | ArrayBufferLike

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

TLSSocket.write method | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method bun.TLSSocket.write | Bun