当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript dgram.Socket类代码示例

本文整理汇总了TypeScript中dgram.Socket的典型用法代码示例。如果您正苦于以下问题:TypeScript Socket类的具体用法?TypeScript Socket怎么用?TypeScript Socket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Socket类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Buffer

    ds.bind();
    ds.bind(41234);
    ds.bind(4123, 'localhost');
    ds.bind(4123, 'localhost', () => { });
    ds.bind(4123, () => { });
    ds.bind(() => { });
    const addr: net.AddressInfo | string = ds.address();
    ds.send(new Buffer("hello"), 0, 5, 5000, "127.0.0.1", (error: Error | null, bytes: number): void => {
    });
    ds.send(new Buffer("hello"), 5000, "127.0.0.1");
    ds.setMulticastInterface("127.0.0.1");
    ds = dgram.createSocket({ type: "udp4", reuseAddr: true, recvBufferSize: 1000, sendBufferSize: 1000, lookup: dns.lookup });
}

{
    let _socket = new dgram.Socket();
    let _boolean: boolean;
    const _err: Error = new Error();
    const _str = '';
    const _rinfo: net.AddressInfo = {
        address: 'asd',
        family: 'asd',
        port: 1,
    };
    /**
     * events.EventEmitter
     * 1. close
     * 2. error
     * 3. listening
     * 4. message
     */
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:dgram.ts

示例2: Promise

 return new Promise((resolve, reject) => {
   try {
     if (arg4 !== undefined) {
       this.socket.send(arg1, arg2, arg3, arg4, arg5, (err, sent) => {
         if (err) {
           reject(err)
         } else {
           resolve(sent)
         }
       })
     } else {
       this.socket.send(arg1, arg2, arg3, (err, sent) => {
         if (err) {
           reject(err)
         } else {
           resolve(sent)
         }
       })
     }
   } catch (err) {
     reject(err)
   }
 })
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:23,代码来源:dgram-as-promised.ts

示例3: setMulticastInterface

 setMulticastInterface (multicastInterface: string): void {
   this.socket.setMulticastInterface(multicastInterface)
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例4: setMulticastTTL

 setMulticastTTL (ttl: number): void {
   this.socket.setMulticastTTL(ttl)
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例5: setTTL

 setTTL (ttl: number): void {
   return this.socket.setTTL(ttl)
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例6: setBroadcast

 setBroadcast (flag: boolean): void {
   this.socket.setBroadcast(flag)
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例7: address

 address (): AddressInfo {
   return this.socket.address() as AddressInfo
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例8: addMembership

 addMembership (multicastAddress: string, multicastInterface?: string): void {
   return this.socket.addMembership(multicastAddress, multicastInterface)
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例9: getRecvBufferSize

 getRecvBufferSize (): number {
   return this.socket.getRecvBufferSize()
 }
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:3,代码来源:dgram-as-promised.ts

示例10: resolve

 this.socket.bind(arg1, () => {
   const address = this.socket.address() as AddressInfo
   resolve(address)
 })
开发者ID:dex4er,项目名称:js-dgram-as-promised,代码行数:4,代码来源:dgram-as-promised.ts


注:本文中的dgram.Socket类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。