i made sure that when i call this funtion, connection is connected.
even than i should  have kept it in loop to try more than once if EAGAIN error is encountered

or Ill appritiate  your comments if there is a better way to do it