Write data with serialize to a socket.

@param   resource  $socket
@param   mixed     $value
@return  boolean
496872
protected function write($socket, $value)
    {
        $value = $this->serialize($value) . PHP_EOL;
        $written = 0;
        while ($written < strlen($value)) {
            $bytes = fwrite($socket, substr($value, $written));
            if ($bytes === false) {
                return false;
            }
            $written += $bytes;
        }
        return true;
    }
1126949
public function write($data)
    {
        $this->_checkStream();
        if (!@fwrite($this->_stream, $data)) {
            $meta_data = $this->getStatus();
            if (!empty($meta_data['timed_out'])) {
                throw new Client\Exception('Timed out writing data to socket');
            }
            throw new Client\Exception('Error writing data to socket');
        }
    }
926371
protected function serialization($value)
    {
        $value = parent::serialization($value);
        $data = [];

        if (!empty($value[self::META_KEY])) {
            $data[self::META_KEY] = $value[self::META_KEY];
            unset($value[self::META_KEY]);
        }

        if (!empty($value[self::LINKS])) {
            $data[self::LINKS] = $value[self::LINKS];
            unset($value[self::LINKS]);
        }

        $data = array_merge(['data' => $value], $data);

        return $data;
    }
726820
public function stream_write($data)
    {
        $tmp = &$this->_data[$this->_datapos];

        $oldlen = $tmp['l'];
        $res = fwrite($tmp['fp'], $data);
        if ($res === false) {
            return false;
        }

        $tmp['p'] = ftell($tmp['fp']);
        if ($tmp['p'] > $oldlen) {
            $tmp['l'] = $tmp['p'];
            $this->_length += ($tmp['l'] - $oldlen);
        }

        return $res;
    }
795003
protected function socket_send($socket, $message)
	{
		$serialized_message = @serialize($message);
		if ($serialized_message == false)
		{
			$this->log('socket_send failed to serialize message', self::LOG_LEVEL_CRIT);
			return false;
		}

		$header = pack('N', strlen($serialized_message));
		$data = $header . $serialized_message;
		$bytes_left = strlen($data);
		while ($bytes_left > 0)
		{
			$bytes_sent = @socket_write($socket, $data);
			if ($bytes_sent === false)
			{
				$this->log('socket_send error: ' . socket_strerror(socket_last_error()), self::LOG_LEVEL_CRIT);
				return false;
			}

			$bytes_left -= $bytes_sent;
			$data = substr($data, $bytes_sent);
		}

		return true;
	}
677625
public function write($key, $value, $ttl = 0)
    {
        $ttl = ((int) $ttl <= 0) ? 0 : ((int) $ttl + time());

        try {
            $this->delete($key);

            return $this->db
                    ->insert(array(
                        $this->columns['key'] => $this->prefix . $key,
                        $this->columns['data'] => serialize($value),
                        $this->columns['ttl'] => $ttl,
                    ))
                    ->into($this->table);
        } catch (PDOException $e) {
            return false;
        }
    }
234367
public void write(int value) throws IOException {
    if (pos >= buf.length) {
      if (pos >= getMaxPacketLength() && !bufferContainDataAfterMark) {
        //buffer is more than a Packet, must flushBuffer()
        flushBuffer(false);
      } else {
        growBuffer(1);
      }
    }
    buf[pos++] = (byte) value;
  }
681628
private function serializeValue($value)
    {
        if (is_object($value)) {
            return $this->serializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->serializeArrayRecursively($value);
        }

        return $value;
    }
504079
public function write($key, $value)
    {
        $key = $this->_key($key);

        if (!is_int($value)) {
            $value = serialize($value);
        }

        $duration = $this->_config['duration'];
        if ($duration === 0) {
            return $this->_Redis->set($key, $value);
        }

        return $this->_Redis->setEx($key, $duration, $value);
    }
783208
public function write($data = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!is_object($data)) {
			$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
		}
		return fwrite($this->_resource, (string) $data, strlen((string) $data));
	}
696737
public function write($buffer)
    {
        $buffer = (string) $buffer;
        $bufLen = Binary::safeStrlen($buffer);

        $socket = $this->getSocket();
        $written = 0;

        while ($written < $bufLen) {
            // PHP's fwrite does not behave nice in regards to errors, so we wrap
            // it with a temporary error handler and treat every warning/notice as
            // a error
            $failed = false;
            $errorMessage = "Failed to write to socket";
            set_error_handler(function ($errno, $errstr) use (&$failed, &$errorMessage) {
                $failed = true;
                $errorMessage .= ": $errstr ($errno)";
            });
            $byteCount = fwrite($socket, Binary::safeSubstr($buffer, $written));
            restore_error_handler();

            if ($byteCount === 0 && defined('HHVM_VERSION')) {
                $failed = true;
            }

            if ($failed || $byteCount === false) {
                throw new \RuntimeException($errorMessage);
            }

            $written += $byteCount;
        }


        return $written;
    }
302624
protected function serialize($value)
    {
        $result = serialize($value);

        if ($this->connection instanceof PostgresConnection && Str::contains($result, "\0")) {
            $result = base64_encode($result);
        }

        return $result;
    }
970468
protected function writeSocket($cmd, $result = false)
    {
        if (is_null($this->socket)) {
            return false;
        }

        fwrite($this->socket, $cmd . "\r\n");

        if (true == $result) {
            return $this->readSocket();
        }

        return true;
    }
345162
protected function serializeValue($value)
    {
        $serialized = var_export($value, true);
        if ($serialized === 'NULL') {
            $serialized = strtolower($serialized);
        }

        return $serialized;
    }
1325046
public function write($data)
    {

        try {
            // No socket for this server, make one
            if (is_null($this->socket)) {
                $this->create();
            }

            // Send the packet
            return fwrite($this->socket, $data);
        } catch (\Exception $e) {
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }
    }
988489
public boolean writable(final Object socketOrChannel)
    {
        final PollItem it = filter(socketOrChannel, WRITABLE);
        if (it == null) {
            return false;
        }
        return it.isWritable();
    }
269092
public function write($key, $value)
    {
        if($this->_use_PHP_session) {
            $_SESSION[$key] = $value;
        } else if($this->_use_cache_facade) {
            //Write the VALUE to CACHE
        }

        return true;
    }