changed send function return values, 0 on success -1 on failure