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

Bun.udpSocket function | API Reference | Bun

Bun.udpSocket function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/Bun/udpSocketFudpSocket

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/udpSocketFudpSocket

function

udpSocketfunction udpSocketDataBinaryType extends keyof BinaryTypeList = 'buffer'>(options: SocketOptionsDataBinaryType>): PromiseSocketDataBinaryType>>;

Create a UDP socket

@param options

The options to use when creating the server

function udpSocketDataBinaryType extends keyof BinaryTypeList = 'buffer'>(options: ConnectSocketOptionsDataBinaryType>): PromiseConnectedSocketDataBinaryType>>;

Create a UDP socket

@param options

The options to use when creating the server

Referenced typesinterface SocketOptionsDataBinaryType extends BinaryType>binaryType?: DataBinaryTypehostname?: stringport?: numbersocket?: SocketHandlerDataBinaryType>interface SocketDataBinaryType extends BinaryType>readonly address: SocketAddressreadonly binaryType: keyof BinaryTypeListreadonly closed: booleanreadonly hostname: stringreadonly port: numberaddMembership(multicastAddress: string,interfaceAddress?: string): boolean;

Join a multicast group.

@param multicastAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

addSourceSpecificMembership(sourceAddress: string,groupAddress: string,interfaceAddress?: string): boolean;

Join a source-specific multicast group.

@param sourceAddress

The source address

@param groupAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

close(): void;dropMembership(multicastAddress: string,interfaceAddress?: string): boolean;

Leave a multicast group.

@param multicastAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

dropSourceSpecificMembership(sourceAddress: string,groupAddress: string,interfaceAddress?: string): boolean;

Leave a source-specific multicast group.

@param sourceAddress

The source address

@param groupAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

ref(): void;reload(handler: SocketHandlerDataBinaryType>): void;send(data: Data,port: number,address: string): boolean;sendMany(packets: readonly number | Data[]): number;setBroadcast(enabled: boolean): boolean;

Enable or disable SO_BROADCAST socket option.

@param enabled

Whether to enable broadcast

@returns

The enabled value

setMulticastInterface(interfaceAddress: string): boolean;

Set the IP_MULTICAST_IF socket option to specify the outgoing interface for multicast packets.

@param interfaceAddress

The address of the interface to use

@returns

true on success

setMulticastLoopback(enabled: boolean): boolean;

Enable or disable IP_MULTICAST_LOOP socket option.

@param enabled

Whether to enable multicast loopback

@returns

The enabled value

setMulticastTTL(ttl: number): number;

Set the IP_MULTICAST_TTL socket option.

@param ttl

Time to live value for multicast packets

@returns

The TTL value

setTTL(ttl: number): number;

Set the IP_TTL socket option.

@param ttl

Time to live value

@returns

The TTL value

unref(): void;interface ConnectSocketOptionsDataBinaryType extends BinaryType>binaryType?: DataBinaryTypeconnect: { hostname: string; port: number }hostname?: stringport?: numbersocket?: ConnectedSocketHandlerDataBinaryType>interface ConnectedSocketDataBinaryType extends BinaryType>readonly address: SocketAddressreadonly binaryType: keyof BinaryTypeListreadonly closed: booleanreadonly hostname: stringreadonly port: numberreadonly remoteAddress: SocketAddressaddMembership(multicastAddress: string,interfaceAddress?: string): boolean;

Join a multicast group.

@param multicastAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

addSourceSpecificMembership(sourceAddress: string,groupAddress: string,interfaceAddress?: string): boolean;

Join a source-specific multicast group.

@param sourceAddress

The source address

@param groupAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

close(): void;dropMembership(multicastAddress: string,interfaceAddress?: string): boolean;

Leave a multicast group.

@param multicastAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

dropSourceSpecificMembership(sourceAddress: string,groupAddress: string,interfaceAddress?: string): boolean;

Leave a source-specific multicast group.

@param sourceAddress

The source address

@param groupAddress

The multicast group address

@param interfaceAddress

Optional interface address to use

@returns

true on success

ref(): void;reload(handler: ConnectedSocketHandlerDataBinaryType>): void;send(data: Data): boolean;sendMany(packets: readonly Data[]): number;setBroadcast(enabled: boolean): boolean;

Enable or disable SO_BROADCAST socket option.

@param enabled

Whether to enable broadcast

@returns

The enabled value

setMulticastInterface(interfaceAddress: string): boolean;

Set the IP_MULTICAST_IF socket option to specify the outgoing interface for multicast packets.

@param interfaceAddress

The address of the interface to use

@returns

true on success

setMulticastLoopback(enabled: boolean): boolean;

Enable or disable IP_MULTICAST_LOOP socket option.

@param enabled

Whether to enable multicast loopback

@returns

The enabled value

setMulticastTTL(ttl: number): number;

Set the IP_MULTICAST_TTL socket option.

@param ttl

Time to live value for multicast packets

@returns

The TTL value

setTTL(ttl: number): number;

Set the IP_TTL socket option.

@param ttl

Time to live value

@returns

The TTL value

unref(): void;

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 →

Bun.udpSocket function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function bun.udpSocket | Bun