我正在为介绍性网络类(class)开发 P2P Twitter 客户端。我正在尝试为我的同龄人提供一种注册自己的方式,以便其他同龄人可以发现它。我正在创建一个 DNS TXT 记录,以便我可以调用 DNSSD.Register()。但是,当调用此方法时,我收到一条错误消息:
导致此错误的原因 (java):“位置 0x0 rip=0x106282bae 的无效内存访问”
这是导致它的方法:
import com.apple.dnssd.*;
public static void announce()throws com.apple.dnssd.DNSSDException{
TXTRecord txtRec = new TXTRecord();
txtRec.set("Version", "1.1");
txtRec.set("EncryptionSupport", "false");
txtRec.set("DisplayName", profile.getPropertyValue("UserName"));
txtRec.set("UserID", profile.getPropertyValue("UserID"));
RegisterListener myRegisterListener = null;
DNSSDRegistration reg = null;
RegisterListener myRegistrationListener = null;
reg = DNSSD.register
(0, DNSSD.ALL_INTERFACES, profile.getPropertyValue("UserName"),
profile.getPropertyValue("DNSSDServiceName"),
null, null, 4444, txtRec, myRegistrationListener);
}
“reg = ...”行是导致错误发生的行。关于我做错了什么的任何想法?其中很多摘 self 不完全理解的示例。
最佳答案
问题是 DNSSD.register() 方法的最后一个参数应该是一个有效的对象。 由于您将它作为 NULL 指针传递,因此当它被调用时,您将获得对 0x0 位置的无效访问。
看看 docs对于这种方法。
关于java - 是什么导致此错误 (java) : "Invalid memory access of location 0x0 rip=0x106282bae",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13665828/