public function send($data) {
        if($this->socketsEnabled) {
            $sendResult = socket_send($this->socket, $data, strlen($data), 0);
            if ($sendResult === false) {
                throw new SocketException(socket_last_error($this->socket));
            }
        } else {
            $sendResult = fwrite($this->socket, $data, strlen($data));
            if ($sendResult === false) {
                throw new SocketException('Could not send data.');
            }
        }
    }