BigZero said:
Well i do not known where to post so i m posting here only, let this
can help u to under stand.
here is my code i m using snmp4j pack,
That is much clearer. In your original posting (in *this* thread) you
mentioned UDP Datagrams, you said nothing about SNMP. A better subject
line might have been "Problems with SNMP using SNMP4J".
I can't help you with SNMP, particularly as there are many different
SNMP stacks.
What follows is of no use to the OP (BigZero) - but here is a simple
example in case any other google/newsreader-user read this thread
because the OP mentioned "Echo packet" "Broadcast" "UDP" "datagram":
------------------------------ 8< ------------------------------------
public class UdpPing {
// NOTE: needs extending to capture *all* reponders.
static final String BROADCAST = "255.255.255.255";
static final int ECHOPORT = 7;
public static void main(String[] args) {
try {
DatagramSocket socket = new DatagramSocket();
socket.setSoTimeout(1000); // in mSec.
// send request
byte[] buf = new byte[256];
InetAddress address;
address = InetAddress.getByName(BROADCAST);
DatagramPacket packet = new DatagramPacket(buf, buf.length,
address, ECHOPORT);
socket.send(packet);
// get response
packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
// see who responded first
InetAddress responder = packet.getAddress();
System.out.println(responder + " responded.");
socket.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
------------------------------ 8< ------------------------------------