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


Java DNSOutgoing类代码示例

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


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

示例1: addAnswers

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException
{
    DNSOutgoing newOut = out;
    if (!_info.hasData())
    {
        long now = System.currentTimeMillis();
        newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN), now);
        newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN), now);
        if (_info.getServer().length() > 0)
        {
            newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN), now);
            newOut = this.addAnswer(newOut, (DNSRecord) this.getDns().getCache().getDNSEntry(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN), now);
        }
    }
    return newOut;
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:18,代码来源:ServiceInfoResolver.java

示例2: addQuestions

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException
{
    DNSOutgoing newOut = out;
    if (!_info.hasData())
    {
        newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        if (_info.getServer().length() > 0)
        {
            newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
            newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        }
    }
    return newOut;
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:17,代码来源:ServiceInfoResolver.java

示例3: testCreateQuery

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Test
public void testCreateQuery() throws IOException {
    String serviceName = "_00000000-0b44-f234-48c8-071c565644b3._sub._home-sharing._tcp.local.";
    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
    assertNotNull("Could not create the outgoing message", out);
    out.addQuestion(DNSQuestion.newQuestion(serviceName, DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, true));
    byte[] data = out.data();
    assertNotNull("Could not encode the outgoing message", data);
    byte[] expected = new byte[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x25, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2d, 0x30, 0x62, 0x34, 0x34, 0x2d, 0x66, 0x32, 0x33, 0x34, 0x2d, 0x34, 0x38, 0x63, 0x38,
            0x2d, 0x30, 0x37, 0x31, 0x63, 0x35, 0x36, 0x35, 0x36, 0x34, 0x34, 0x62, 0x33, 0x4, 0x5f, 0x73, 0x75, 0x62, 0xd, 0x5f, 0x68, 0x6f, 0x6d, 0x65, 0x2d, 0x73, 0x68, 0x61, 0x72, 0x69, 0x6e, 0x67, 0x4, 0x5f, 0x74, 0x63, 0x70, 0x5, 0x6c,
            0x6f, 0x63, 0x61, 0x6c, 0x0, 0x0, (byte) 0xff, 0x0, 0x1 };
    for (int i = 0; i < data.length; i++) {
        assertEquals("the encoded message is not what is expected at index " + i, expected[i], data[i]);
    }
    DatagramPacket packet = new DatagramPacket(data, 0, data.length);
    DNSIncoming in = new DNSIncoming(packet);
    assertTrue("Wrong packet type.", in.isQuery());
    assertEquals("Wrong number of questions.", 1, in.getNumberOfQuestions());
    for (DNSQuestion question : in.getQuestions()) {
        assertEquals("Wrong question name.", serviceName, question.getName());
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:23,代码来源:DNSMessageTest.java

示例4: buildOutgoingForDNS

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.UNIQUE, this.getTTL())) {
        newOut = this.addAnswer(newOut, null, answer);
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:9,代码来源:Announcer.java

示例5: buildOutgoingForInfo

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    for (DNSRecord answer : info.answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) {
        newOut = this.addAnswer(newOut, null, answer);
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:9,代码来源:Announcer.java

示例6: buildOutgoingForDNS

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    newOut.addQuestion(DNSQuestion.newQuestion(this.getDns().getLocalHost().getName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
    for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.CLASS_ANY, DNSRecordClass.NOT_UNIQUE, this.getTTL())) {
        newOut = this.addAuthoritativeAnswer(newOut, answer);
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:10,代码来源:Prober.java

示例7: buildOutgoingForInfo

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(info.getQualifiedName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
    // the "unique" flag should be not set here because these answers haven't been proven unique yet this means the record will not exactly match the announcement record
    newOut = this.addAuthoritativeAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, this.getTTL(), info.getPriority(), info.getWeight(), info.getPort(), this.getDns().getLocalHost()
            .getName()));
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:10,代码来源:Prober.java

示例8: addAnswers

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    long now = System.currentTimeMillis();
    for (ServiceInfo info : this.getDns().getServices().values()) {
        newOut = this.addAnswer(newOut, new DNSRecord.Pointer(info.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getQualifiedName()), now);
        // newOut = this.addAnswer(newOut, new DNSRecord.Service(info.getQualifiedName(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, info.getPriority(), info.getWeight(), info.getPort(),
        // this.getDns().getLocalHost().getName()), now);
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:12,代码来源:ServiceResolver.java

示例9: addQuestions

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_type, DNSRecordType.TYPE_PTR, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
    // newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_type, DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:8,代码来源:ServiceResolver.java

示例10: addAnswers

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addAnswers(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    long now = System.currentTimeMillis();
    for (String type : this.getDns().getServiceTypes().keySet()) {
        ServiceTypeEntry typeEntry = this.getDns().getServiceTypes().get(type);
        newOut = this.addAnswer(newOut, new DNSRecord.Pointer("_services._dns-sd._udp.local.", DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, DNSConstants.DNS_TTL, typeEntry.getType()), now);
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:11,代码来源:TypeResolver.java

示例11: addQuestions

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing addQuestions(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    if (!_info.hasData()) {
        newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_SRV, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getQualifiedName(), DNSRecordType.TYPE_TXT, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        if (_info.getServer().length() > 0) {
            newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_A, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
            newOut = this.addQuestion(newOut, DNSQuestion.newQuestion(_info.getServer(), DNSRecordType.TYPE_AAAA, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
        }
    }
    return newOut;
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:14,代码来源:ServiceInfoResolver.java

示例12: run

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
public void run() {
    try {
        if (this.getDns().isCanceling() || this.getDns().isCanceled()) {
            this.cancel();
        } else {
            if (_count++ < 3) {
                if (logger.isLoggable(Level.FINER)) {
                    logger.finer(this.getName() + ".run() JmDNS " + this.description());
                }
                DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_QUERY);
                out = this.addQuestions(out);
                if (this.getDns().isAnnounced()) {
                    out = this.addAnswers(out);
                }
                if (!out.isEmpty()) {
                    this.getDns().send(out);
                }
            } else {
                // After three queries, we can quit.
                this.cancel();
            }
        }
    } catch (Throwable e) {
        logger.log(Level.WARNING, this.getName() + ".run() exception ", e);
        this.getDns().recover();
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:29,代码来源:DNSResolverTask.java

示例13: buildOutgoingForDNS

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.UNIQUE, this.getTTL())) {
        newOut = this.addAnswer(newOut, null, answer);
    }
    return newOut;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:9,代码来源:Announcer.java

示例14: buildOutgoingForInfo

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForInfo(ServiceInfoImpl info, DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    for (DNSRecord answer : info.answers(DNSRecordClass.UNIQUE, this.getTTL(), this.getDns().getLocalHost())) {
        newOut = this.addAnswer(newOut, null, answer);
    }
    return newOut;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:9,代码来源:Announcer.java

示例15: buildOutgoingForDNS

import javax.jmdns.impl.DNSOutgoing; //导入依赖的package包/类
@Override
protected DNSOutgoing buildOutgoingForDNS(DNSOutgoing out) throws IOException {
    DNSOutgoing newOut = out;
    newOut.addQuestion(DNSQuestion.newQuestion(this.getDns().getLocalHost().getName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
    for (DNSRecord answer : this.getDns().getLocalHost().answers(DNSRecordClass.NOT_UNIQUE, this.getTTL())) {
        newOut = this.addAuthoritativeAnswer(newOut, answer);
    }
    return newOut;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:10,代码来源:Prober.java


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