yes it's if I create the socket without specifying the port.
I think port 162 was binded by snmpd running as root
Thanks a lot for your help
> > > I'm trying to send a TRAP PDU using a java SNMP stack
> > > and I got following exception:
> > > java.net.BindException: Address in use: Cannot bind
> > > it lloks like the snmpd is locking the port
> > > here 's the piece of code:
> > > ....
> > > static final SNMP_TRAP_PORT 162;
> > > dSocket = new DatagramSocket(SNMP_TRAP_PORT);
> > > DatagramPacket outPacket = new DatagramPacket(messageEncoding,
> > > messageEncoding.length, hostAddress, SNMP_TRAP_PORT);
> > > dSocket.send(outPacket);
> > > Also, when I'm trying to run this on a Unix I got:
> > > java.net.BindException: permission denied
> > > I though I could send a SNMP packet without my program beeing root on
> UNIX? NO?
> > can I send SNMP packets using another port???
> Hi mike_stephanos,
> to my knowledge snmp-packets can be sent from any source-port...
> port 162/udp is the (wellknown) portnumber of the receiving-progess
> (usually part
> of an snmp-monitoring istallation.)
> would this not be the case (meaning if one would have to use 162/udp as
> source-port as well),
> - only root-processes would be able to send traps,
> - only a single process (on a system) could send traps at a certain time,
> because not more than one process can bind to this port at a certain
> So, give it a go, and try with "dSocket = new DatagramSocket(0);" ...
> the system should assign this socket a portnumber from the dynamic-range
> (one that is available of corse) when you send the first packet...
> the socket will hold this portnumber until you close it.
> regards ... rainer