导致此错误的原因(java):"位置0x0的内存访问无效rip = 0x106282bae"

Cap*_*ack 1 java networking p2p bonjour

我正在为推特网络课程的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);
    }
Run Code Online (Sandbox Code Playgroud)

"reg = ..."行是导致错误发生的行.关于我做错了什么的任何想法?其中很多都来自我不完全理解的例子.

gib*_*oni 6

问题是DNSSD.register()方法的最后一个参数应该是一个有效的对象.由于您将其作为NULL指针传递,因此在调用它时,您将无法访问0x0位置.

看一下这个方法的文档.