implement send and recv logic for client