Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UDP Port Scan problems

Status
Not open for further replies.

jamescpp

IS-IT--Management
Aug 29, 2001
70
US
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
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";
	}
 
Anyone have any ideas here? Thanks!!!!
 
Can you provide some more detail about "UDP does not." Is there an exception being thrown?
 
Sorry, you're right. No errors, just says the ports are closed, when in fact, they are open.

Thanks,
James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top