public function write(string $data): int
    {
        $length = fputs($this->resource, $data, strlen($data));
        if (false === $length) {
            if (stream_get_meta_data($this->resource)['timed_out']) {
                throw new Timeout(
                        'Writing of ' . strlen($data) . ' bytes failed:'
                        . ' timeout of ' . $this->timeout . ' seconds exceeded'
                );
            }

            throw new ConnectionFailure(
                    'Writing of ' . strlen($data) . ' bytes failed.'
            );
        }

        return $length;
    }
public function write(string $data): int
    {
        $length = fputs($this->resource, $data, strlen($data));
        if (false === $length) {
            if (stream_get_meta_data($this->resource)['timed_out']) {
                throw new Timeout(
                        'Writing of ' . strlen($data) . ' bytes failed:'
                        . ' timeout of ' . $this->timeout . ' seconds exceeded'
                );
            }

            throw new ConnectionFailure(
                    'Writing of ' . strlen($data) . ' bytes failed.'
            );
        }

        return $length;
    }
public function write ( string $ data ) : int { $ length = fputs ( $ this -> resource , $ data , strlen ( $ data ) ) ; if ( false === $ length ) { if ( stream_get_meta_data ( $ this -> resource ) [ 'timed_out' ] ) { throw new Timeout ( 'Writing of ' . strlen ( $ data ) . ' bytes failed:' . ' timeout of ' . $ this -> timeout . ' seconds exceeded' ) ; } throw new ConnectionFailure ( 'Writing of ' . strlen ( $ data ) . ' bytes failed.' ) ; } return $ length ; }
write data to socket

@param   string  $data  data to write
@return  int  amount of bytes written to socket
@throws  \stubbles\peer\ConnectionFailure
@throws  \stubbles\peer\Timeout
write data to socket