src/SimpleSocket.php
public function send($data) {
		$serialized = serialize($data);
		$hdr = pack('N', strlen($serialized)); // 4 byte length
		$buffer = $hdr . $serialized;
		unset($serialized);
		unset($hdr);
		$total = strlen($buffer);
		while ($total > 0) {
			$sent = socket_write($this->socket, $buffer);
			if ($sent === FALSE) {
				throw new SimpleSocketException('Sending failed with: ' . socket_strerror(socket_last_error($this->socket)));
			}
			$total -= $sent;
			$buffer = substr($buffer, $sent);
		}
	}
public function send($data) {
		$serialized = serialize($data);
		$hdr = pack('N', strlen($serialized)); // 4 byte length
		$buffer = $hdr . $serialized;
		unset($serialized);
		unset($hdr);
		$total = strlen($buffer);
		while ($total > 0) {
			$sent = socket_write($this->socket, $buffer);
			if ($sent === FALSE) {
				throw new SimpleSocketException('Sending failed with: ' . socket_strerror(socket_last_error($this->socket)));
			}
			$total -= $sent;
			$buffer = substr($buffer, $sent);
		}
	}
public function send ( $ data ) { $ serialized = serialize ( $ data ) ; $ hdr = pack ( 'N' , strlen ( $ serialized ) ) ; // 4 byte length $ buffer = $ hdr . $ serialized ; unset ( $ serialized ) ; unset ( $ hdr ) ; $ total = strlen ( $ buffer ) ; while ( $ total > 0 ) { $ sent = socket_write ( $ this -> socket , $ buffer ) ; if ( $ sent === FALSE ) { throw new SimpleSocketException ( 'Sending failed with: ' . socket_strerror ( socket_last_error ( $ this -> socket ) ) ) ; } $ total -= $ sent ; $ buffer = substr ( $ buffer , $ sent ) ; } }
Write the data to the socket in a predetermined format
@param mixed $data the data, that should be sent
@throws \QXS\WorkerPool\SimpleSocketException in case of an error
Write the data to the socket in a predetermined format