简体   繁体   English

找不到DatagramPacket构造函数

[英]DatagramPacket Constructor not found

The following code produces "no suitable constructor found" error. 以下代码生成“找不到合适的构造函数”错误。 I am unable to figure out a reason. 我无法弄清楚原因。

   try {
        Sock = new DatagramSocket();             
        InetAddress IP_add=InetAddress.getByName("192.168.1.2");
        DatagramPacket PACKET=new DatagramPacket(buf,buf.length,IP_add,2000);

       } catch (Exception e) {}

There are e few options 有几个选择

  1. Your buf instance is not array of byte, has to be byte [] 你的buf实例不是byte的数组,必须是byte []
  2. You are using InetAddress not from package java.net 您正在使用InetAddress而不是来自包java.net

Recheck it, I think the first point will help you. 重新检查一下,我认为第一点会对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM