Add some error-handlings socket-connect, -read and -write routines