ported sync recv function