Changeset 13 in flair-dev for trunk/include/FlairCore/Socket.h


Ignore:
Timestamp:
04/08/16 15:39:24 (8 years ago)
Author:
Bayard Gildas
Message:

formatting script + include reformatted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/FlairCore/Socket.h

    r2 r13  
    2020class Socket_impl;
    2121
    22 namespace flair
    23 {
    24 namespace core
    25 {
     22namespace flair {
     23namespace core {
    2624
    27     /*! \class Socket
    28     *
    29     * \brief Class encapsulating a UDP socket. It assumes packets are coming from only one distant host on a given port.
    30     *
    31     */
    32     class Socket: public Object {
    33     public:
    34         /*!
    35         * \brief Constructor
    36         *
    37         * Construct the client side of the socket
    38         *
    39         * \param parent parent
    40         * \param name name
    41         * \param address server address (ex 192.168.1.1:9000)
    42         * \param broadcast true if address is a broadcast address
    43         */
    44         Socket(const Object* parent, std::string name,std::string address,bool broadcast=false);
     25/*! \class Socket
     26*
     27* \brief Class encapsulating a UDP socket. It assumes packets are coming from
     28*only one distant host on a given port.
     29*
     30*/
     31class Socket : public Object {
     32public:
     33  /*!
     34  * \brief Constructor
     35  *
     36  * Construct the client side of the socket
     37  *
     38  * \param parent parent
     39  * \param name name
     40  * \param address server address (ex 192.168.1.1:9000)
     41  * \param broadcast true if address is a broadcast address
     42  */
     43  Socket(const Object *parent, std::string name, std::string address,
     44         bool broadcast = false);
    4545
    46         /*!
    47         * \brief Constructor
    48         *
    49         * Construct the server side of the socket
    50         *
    51         * \param parent parent
    52         * \param name name
    53         * \param port listening port
    54         */
    55         Socket(const Object* parent, std::string name,uint16_t port);
     46  /*!
     47  * \brief Constructor
     48  *
     49  * Construct the server side of the socket
     50  *
     51  * \param parent parent
     52  * \param name name
     53  * \param port listening port
     54  */
     55  Socket(const Object *parent, std::string name, uint16_t port);
    5656
    57         /*!
    58         * \brief Destructor
    59         *
    60         */
    61         ~Socket();
     57  /*!
     58  * \brief Destructor
     59  *
     60  */
     61  ~Socket();
    6262
    63         /*!
    64         * \brief Send a message
    65         *
    66         * In case of a broadcast Socket, Parent()->ObjectName() is used as source of the message, this name should be unique.
    67         *
    68         * \param message message
    69         */
    70         void SendMessage(std::string message);
     63  /*!
     64  * \brief Send a message
     65  *
     66  * In case of a broadcast Socket, Parent()->ObjectName() is used as source of
     67  *the message, this name should be unique.
     68  *
     69  * \param message message
     70  */
     71  void SendMessage(std::string message);
    7172
    72         /*!
    73         * \brief Send a message
    74         *
    75         * \param message message
    76         * \param message_len message length
    77         */
    78         void SendMessage(const char* message,size_t message_len);
     73  /*!
     74  * \brief Send a message
     75  *
     76  * \param message message
     77  * \param message_len message length
     78  */
     79  void SendMessage(const char *message, size_t message_len);
    7980
    80         /*!
    81         * \brief Receive a message
    82         *
    83         * Receive a message and wait up to timeout. \n
    84         * If src and src_len are specified, the source of the message will be
    85         * copied in the src buffer. \n
    86         * Note that in case of a broadcast socket, own messages are filtered and
    87         * are not received.
    88         *
    89         * \param buf buffer to put the message
    90         * \param buf_len buffer length
    91         * \param timeout timeout
    92         * \param src buffer to put source name
    93         * \param src_len buffer length
    94         *
    95         * \return size of the received message
    96         */
    97         ssize_t RecvMessage(char* buf,size_t buf_len,Time timeout,char* src=NULL,size_t* src_len=NULL);
     81  /*!
     82  * \brief Receive a message
     83  *
     84  * Receive a message and wait up to timeout. \n
     85  * If src and src_len are specified, the source of the message will be
     86  * copied in the src buffer. \n
     87  * Note that in case of a broadcast socket, own messages are filtered and
     88  * are not received.
     89  *
     90  * \param buf buffer to put the message
     91  * \param buf_len buffer length
     92  * \param timeout timeout
     93  * \param src buffer to put source name
     94  * \param src_len buffer length
     95  *
     96  * \return size of the received message
     97  */
     98  ssize_t RecvMessage(char *buf, size_t buf_len, Time timeout, char *src = NULL,
     99                      size_t *src_len = NULL);
    98100
    99         void NetworkToHost(char *data,size_t dataSize);
    100         void HostToNetwork(char *data,size_t dataSize);
     101  void NetworkToHost(char *data, size_t dataSize);
     102  void HostToNetwork(char *data, size_t dataSize);
    101103
    102     private:
    103        class Socket_impl* pimpl_;
    104     };
     104private:
     105  class Socket_impl *pimpl_;
     106};
    105107
    106108} // end namespace core
Note: See TracChangeset for help on using the changeset viewer.