fixed the I/O bugs of socket