Added exception if socket write failed