private function sendOtherNetworkMessage($to, $message, $network) {\r
$message = $this->getMessage($message, $network);\r
$len = strlen($message);\r
- // TODO Introduce error checking for message sending\r
- $this->ns_writeln("UUM $this->id $to $network 1 $len");\r
- $this->ns_writedata($Message);\r
+ if ($this->ns_writeln("UUM $this->id $to $network 1 $len") === false) {\r
+ return false;\r
+ }\r
+ if ($this->ns_writedata($Message)) {\r
+ return false;\r
+ }\r
$this->debug_message("*** Sent to $to (network: $network):\n$Message");\r
return true;\r
}\r
* Also increments id\r
* \r
* @param string $data Line to write to socket\r
- * @return void\r
+ * @return mixed Bytes written or false on failure\r
*/\r
private function ns_writeln($data) {\r
- @fwrite($this->NSfp, $data."\r\n");\r
- $this->debug_message("NS: >>> $data");\r
- $this->id++;\r
+ $result = @fwrite($this->NSfp, $data."\r\n");\r
+ if ($result !== false) {\r
+ $this->debug_message("NS: >>> $data");\r
+ $this->id++;\r
+ }\r
+ return $result;\r
}\r
\r
/**\r
* Write data to NS socket\r
* \r
* @param string $data Data to write to socket\r
- * @return void\r
+ * @return mixed Bytes written or false on failure\r
*/\r
private function ns_writedata($data) {\r
- @fwrite($this->NSfp, $data);\r
- $this->debug_message("NS: >>> $data");\r
+ $result = @fwrite($this->NSfp, $data);\r
+ if ($result !== false) {\r
+ $this->debug_message("NS: >>> $data");\r
+ }\r
+ return $result;\r
}\r
\r
/**\r