本文整理汇总了Java中javax.jmdns.impl.DNSIncoming类的典型用法代码示例。如果您正苦于以下问题:Java DNSIncoming类的具体用法?Java DNSIncoming怎么用?Java DNSIncoming使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DNSIncoming类属于javax.jmdns.impl包,在下文中一共展示了DNSIncoming类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testCreateQuery
import javax.jmdns.impl.DNSIncoming; //导入依赖的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
示例2: addAnswer
import javax.jmdns.impl.DNSIncoming; //导入依赖的package包/类
/**
* Add an answer if it is not suppressed.
*
* @param out
* outgoing message
* @param in
* incoming request
* @param rec
* DNS record answer
* @return outgoing message for the next answer
* @exception IOException
*/
public DNSOutgoing addAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException {
DNSOutgoing newOut = out;
try {
newOut.addAnswer(in, 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.addAnswer(in, rec);
}
return newOut;
}
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:32,代码来源:DNSTask.java
示例3: addAdditionalAnswer
import javax.jmdns.impl.DNSIncoming; //导入依赖的package包/类
/**
* Add an additional answer to the record. Omit if there is no room.
*
* @param out
* outgoing message
* @param in
* incoming request
* @param rec
* DNS record answer
* @return outgoing message for the next answer
* @exception IOException
*/
public DNSOutgoing addAdditionalAnswer(DNSOutgoing out, DNSIncoming in, DNSRecord rec) throws IOException {
DNSOutgoing newOut = out;
try {
newOut.addAdditionalAnswer(in, 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.addAdditionalAnswer(in, rec);
}
return newOut;
}
开发者ID:mwaylabs,项目名称:JmDNS,代码行数:32,代码来源:DNSTask.java
示例4: testIncomingOverflow
import javax.jmdns.impl.DNSIncoming; //导入依赖的package包/类
@Test
public void testIncomingOverflow() {
try {
// The DNSIncoming constructor should probably do bounds checking on the following parts of the package: questions, answers, authorities, additionals
// The package above results in these values
// questions -> 513
// answers -> 4
// authorities -> 1648
// additionals -> 30050
new DNSIncoming(new DatagramPacket(nmap_scan_package, nmap_scan_package.length, InetAddress.getByName(DNSConstants.MDNS_GROUP), DNSConstants.MDNS_PORT));
fail("This message should have triggered an IO exception");
} catch (Exception exception) {
// All is OK
}
}
开发者ID:josephw,项目名称:jmdns,代码行数:16,代码来源:DNSMessageTest.java
示例5: testCreateAnswer
import javax.jmdns.impl.DNSIncoming; //导入依赖的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
示例6: Responder
import javax.jmdns.impl.DNSIncoming; //导入依赖的package包/类
public Responder(JmDNSImpl jmDNSImpl, DNSIncoming in, int port) {
super(jmDNSImpl);
this._in = in;
this._unicast = (port != DNSConstants.MDNS_PORT);
}
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:6,代码来源:Responder.java
示例7: Responder
import javax.jmdns.impl.DNSIncoming; //导入依赖的package包/类
public Responder(JmDNSImpl jmDNSImpl, DNSIncoming in, int port)
{
super(jmDNSImpl);
this._in = in;
this._unicast = (port != DNSConstants.MDNS_PORT);
}
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:7,代码来源:Responder.java
注:本文中的javax.jmdns.impl.DNSIncoming类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论