unify send/recv functions