change some function names
fix a bug where part of a message would be lost on EAGAIN event