This file is indexed.

/usr/include/Arcus/Socket.h is in libarcus-dev 3.1.0-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * This file is part of libArcus
 *
 * Copyright (C) 2015 Ultimaker b.v. <a.hiemstra@ultimaker.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License v3.0 as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License v3.0 for more details.
 * You should have received a copy of the GNU Lesser General Public License v3.0
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef ARCUS_SOCKET_H
#define ARCUS_SOCKET_H

#include <memory>

#include "Types.h"
#include "Error.h"
#include "ArcusExport.h"

namespace Arcus
{
    class SocketListener;

    /**
     * \brief Threaded socket class.
     *
     * This class represents a socket and the logic for parsing and handling
     * protobuf messages that can be sent and received over this socket.
     *
     * Please see the README in libArcus for more details.
     */
    class ARCUS_EXPORT Socket
    {
    public:
        Socket();
        virtual ~Socket();

        /**
         * Get the socket state.
         *
         * \return The current socket state.
         */
        SocketState::SocketState getState() const;

        /**
         * Get the last error.
         *
         * \return The last error that occurred.
         */
        Error getLastError() const;

        /**
         * Clear any error that was set previously.
         */
        void clearError();

        /**
         * Register a new type of Message to handle.
         *
         * If the socket state is not SocketState::Initial, this method will do nothing.
         *
         * \param message_type An instance of the Message that will be used as factory object.
         *
         */
        bool registerMessageType(const google::protobuf::Message* message_type);

        /**
         * Register all message types contained in a Protobuf protocol description file.
         *
         * If the socket state is not SocketState::Initial, this method will do nothing.
         *
         * \param file_name The absolute path to a Protobuf protocol file to load message types from.
         */
        bool registerAllMessageTypes(const std::string& file_name);

        /**
         * Add a listener object that will be notified of socket events.
         *
         * If the socket state is not SocketState::Initial, this method will do nothing.
         *
         * \param listener The listener to add.
         */
        void addListener(SocketListener* listener);
        /**
         * Remove a listener from the list of listeners.
         *
         * If the socket state is not SocketState::Initial, this method will do nothing.
         *
         * \param listener The listener to remove.
         */
        void removeListener(SocketListener* listener);

        /**
         * Connect to an address and port.
         *
         * \param address The IP address to connect to.
         * \param port The port to connect to.
         */
        void connect(const std::string& address, int port);
        /**
         * Listen for connections on an address and port.
         *
         * \param address The IP address to listen on.
         * \param port The port to listen on.
         */
        void listen(const std::string& address, int port);
        /**
         * Close the connection and stop handling any messages.
         */
        void close();

        /**
         * Reset a socket for re-use. State must be Closed or Error
         */
        void reset();

        /**
         * Send a message across the socket.
         */
        void sendMessage(MessagePtr message);

        /**
         * Remove and return the next pending message from the queue.
         */
        MessagePtr takeNextMessage();

        /**
         * Create an instance of a Message class.
         *
         * \param type_name The type name of the Message type to create an instance of.
         */
        MessagePtr createMessage(const std::string& type_name);

    private:
        // Copy and assignment is not supported.
        Socket(const Socket&);
        Socket& operator=(const Socket& other);

        class Private;
        const std::unique_ptr<Private> d;
    };
}

#endif // ARCUS_SOCKET_H