Handle fwrite errors in socket class
Handle fwrite errors in socket class