error handle for socket connect/write