Someone correct me if I'm wrong, but there is no need to use port 162 as the
source port when sending traps. You only need to have the destination port
as 162. So in your code, change the constructor of the DatagramSocket to
not specify a source port i.e to "new DatagramSocket()". The OS will
allocate a free local port.
But as noted above there is no need to use a 'priviledged' port.
But it won't matter now as the OS is now allocating a free port for you.
Alan J. McFarlane
Please follow-up in the newsgroup for the benefit of all.