• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DNSQuestion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addQuestions

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例2: testCreateQuery

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例3: addQuestion

import javax.jmdns.impl.DNSQuestion; //导入依赖的package包/类
/**
 * Add a question to the message.
 * 
 * @param out
 *            outgoing message
 * @param rec
 *            DNS question
 * @return outgoing message for the next question
 * @exception IOException
 */
public DNSOutgoing addQuestion(DNSOutgoing out, DNSQuestion rec) throws IOException {
    DNSOutgoing newOut = out;
    try {
        newOut.addQuestion(rec);
    } catch (final IOException e) {
        int flags = newOut.getFlags();
        boolean multicast = newOut.isMulticast();
        int maxUDPPayload = newOut.getMaxUDPPayload();
        int id = newOut.getId();

        newOut.setFlags(flags | DNSConstants.FLAGS_TC);
        newOut.setId(id);
        this._jmDNSImpl.send(newOut);

        newOut = new DNSOutgoing(flags, multicast, maxUDPPayload);
        newOut.addQuestion(rec);
    }
    return newOut;
}
 
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:30,代码来源:DNSTask.java


示例4: start

import javax.jmdns.impl.DNSQuestion; //导入依赖的package包/类
@Override
public void start(Timer timer) {
    // According to draft-cheshire-dnsext-multicastdns.txt chapter "7 Responding":
    // We respond immediately if we know for sure, that we are the only one who can respond to the query.
    // In all other cases, we respond within 20-120 ms.
    //
    // According to draft-cheshire-dnsext-multicastdns.txt chapter "6.2 Multi-Packet Known Answer Suppression":
    // We respond after 20-120 ms if the query is truncated.

    boolean iAmTheOnlyOne = true;
    for (DNSQuestion question : _in.getQuestions()) {
        if (logger.isLoggable(Level.FINEST)) {
            logger.finest(this.getName() + "start() question=" + question);
        }
        iAmTheOnlyOne = question.iAmTheOnlyOne(this.getDns());
        if (!iAmTheOnlyOne) {
            break;
        }
    }
    int delay = (iAmTheOnlyOne && !_in.isTruncated()) ? 0 : DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + JmDNSImpl.getRandom().nextInt(DNSConstants.RESPONSE_MAX_WAIT_INTERVAL - DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + 1) - _in.elapseSinceArrival();
    if (delay < 0) {
        delay = 0;
    }
    if (logger.isLoggable(Level.FINEST)) {
        logger.finest(this.getName() + "start() Responder chosen delay=" + delay);
    }
    if (!this.getDns().isCanceling() && !this.getDns().isCanceled()) {
        timer.schedule(this, delay);
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:31,代码来源:Responder.java


示例5: buildOutgoingForDNS

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例6: buildOutgoingForInfo

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例7: addQuestions

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例8: addQuestions

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例9: buildOutgoingForDNS

import javax.jmdns.impl.DNSQuestion; //导入依赖的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


示例10: start

import javax.jmdns.impl.DNSQuestion; //导入依赖的package包/类
@Override
public void start(Timer timer)
{
    // According to draft-cheshire-dnsext-multicastdns.txt chapter "7 Responding":
    // We respond immediately if we know for sure, that we are the only one who can respond to the query.
    // In all other cases, we respond within 20-120 ms.
    //
    // According to draft-cheshire-dnsext-multicastdns.txt chapter "6.2 Multi-Packet Known Answer Suppression":
    // We respond after 20-120 ms if the query is truncated.

    boolean iAmTheOnlyOne = true;
    for (DNSQuestion question : _in.getQuestions())
    {
        if (logger.isLoggable(Level.FINEST))
        {
            logger.finest(this.getName() + "start() question=" + question);
        }
        iAmTheOnlyOne = question.iAmTheOnlyOne(this.getDns());
        if (!iAmTheOnlyOne)
        {
            break;
        }
    }
    int delay = (iAmTheOnlyOne && !_in.isTruncated()) ? 0 : DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + JmDNSImpl.getRandom().nextInt(DNSConstants.RESPONSE_MAX_WAIT_INTERVAL - DNSConstants.RESPONSE_MIN_WAIT_INTERVAL + 1) - _in.elapseSinceArrival();
    if (delay < 0)
    {
        delay = 0;
    }
    if (logger.isLoggable(Level.FINEST))
    {
        logger.finest(this.getName() + "start() Responder chosen delay=" + delay);
    }
    if (!this.getDns().isCanceling() && !this.getDns().isCanceled())
    {
        timer.schedule(this, delay);
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:38,代码来源:Responder.java


示例11: buildOutgoingForDNS

import javax.jmdns.impl.DNSQuestion; //导入依赖的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:blackshadowwalker,项目名称:log4j-collector,代码行数:12,代码来源:Prober.java


示例12: buildOutgoingForInfo

import javax.jmdns.impl.DNSQuestion; //导入依赖的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:blackshadowwalker,项目名称:log4j-collector,代码行数:11,代码来源:Prober.java


示例13: addQuestions

import javax.jmdns.impl.DNSQuestion; //导入依赖的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:blackshadowwalker,项目名称:log4j-collector,代码行数:9,代码来源:ServiceResolver.java


示例14: ServiceInfoResolver

import javax.jmdns.impl.DNSQuestion; //导入依赖的package包/类
public ServiceInfoResolver(JmDNSImpl jmDNSImpl, ServiceInfoImpl info)
{
    super(jmDNSImpl);
    this._info = info;
    info.setDns(this.getDns());
    this.getDns().addListener(info, DNSQuestion.newQuestion(info.getQualifiedName(), DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE));
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:8,代码来源:ServiceInfoResolver.java


示例15: testCreateAnswer

import javax.jmdns.impl.DNSQuestion; //导入依赖的package包/类
@Test
public void testCreateAnswer() throws IOException {
    String serviceType = "_home-sharing._tcp.local.";
    String serviceName = "Pierre." + serviceType;
    DNSOutgoing out = new DNSOutgoing(DNSConstants.FLAGS_QR_RESPONSE | DNSConstants.FLAGS_AA, false);
    assertNotNull("Could not create the outgoing message", out);
    out.addQuestion(DNSQuestion.newQuestion(serviceName, DNSRecordType.TYPE_ANY, DNSRecordClass.CLASS_IN, true));
    long now = (new Date()).getTime();
    out.addAnswer(new DNSRecord.Pointer(serviceType, DNSRecordClass.CLASS_IN, true, DNSConstants.DNS_TTL, serviceName), now);
    out.addAuthorativeAnswer(new DNSRecord.Service(serviceType, DNSRecordClass.CLASS_IN, true, DNSConstants.DNS_TTL, 1, 20, 8080, "panoramix.local."));
    byte[] data = out.data();
    assertNotNull("Could not encode the outgoing message", data);
    // byte[] expected = new byte[] { 0x0, 0x0, (byte) 0x84, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x6, 0x50, 0x69, 0x65, 0x72, 0x72, 0x65, 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, (byte) 0xc0, 0x13, 0x0, 0xc, 0x0, 0x1, 0x0, 0x0, 0xe, 0xf, 0x0, 0x21, 0x6, 0x50, 0x69, 0x65, 0x72, 0x72, 0x65, 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, (byte) 0xc0, 0x13, 0x0, 0x21, 0x0, 0x1, 0x0, 0x0, 0xe, 0xf, 0x0, 0x17, 0x0, 0x1, 0x0, 0x14, 0x1f, (byte) 0x90, 0x9, 0x70,
    // 0x61, 0x6e, 0x6f, 0x72, 0x61, 0x6d, 0x69, 0x78, 0x5, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x0 };
    // 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.isResponse());
    assertEquals("Wrong number of questions.", 1, in.getNumberOfQuestions());
    assertEquals("Wrong number of answers.", 1, in.getNumberOfAnswers());
    assertEquals("Wrong number of authorities.", 1, in.getNumberOfAuthorities());
    for (DNSQuestion question : in.getQuestions()) {
        assertEquals("Wrong question name.", serviceName, question.getName());
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:31,代码来源:DNSMessageTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PdfDecoder类代码示例发布时间:2022-05-22
下一篇:
Java RepositoryIdFactory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap