or use nssocket, which was basically written to solve that problem