Net-SNMP comes with snmptrapd which handles receiving and decoding of traps. It can then forward the information to another application. This is the only way I hear of people doing this. SNMP is not as simple of a protocol as the name would suggest, I would not recommend rolling your own implementation.