當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。