Hi. I have some code for doing port scans. TCP works well, UDP does not. Can anyone assist? The UDP scan code is below.
Thanks,
James
Thanks,
James
Code:
protected String scanUDP(InetAddress IP, int port)
{
try{
byte [] bytes = new byte[128];
DatagramSocket ds = new DatagramSocket();
DatagramPacket dp = new DatagramPacket(bytes, bytes.length, IP, port);
ds.setSoTimeout(1000);
ds.send(dp);
dp = new DatagramPacket(bytes, bytes.length);
ds.receive(dp);
ds.close();
}
catch(InterruptedIOException e){
return "CLOSED";
}
catch(IOException e){
return "CLOSED";
}
return "OPEN";
}