Changeset 15 in flair-src for trunk/lib/FlairCore/src/TcpSocket.h


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

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/TcpSocket.h

    r2 r15  
    1616#include <ConnectedSocket.h>
    1717
    18 namespace flair
    19 {
    20 namespace core
    21 {
    22     /*! \class TcpSocket
    23     *
    24     * \brief Class encapsulating a TCP socket
    25     *
    26     */
    27     class TcpSocket:public ConnectedSocket {
    28     public:
    29         TcpSocket(const Object* parent,const std::string name,bool blockOnSend=false,bool blockOnReceive=true);
    30         ~TcpSocket();
    31         void Listen(const unsigned int port,const std::string localAddress="ANY");
    32         TcpSocket *Accept(Time timeout=0); //should throw an exception if not a listening socket
    33         bool Connect(const unsigned int distantPort,const std::string distantAddress,Time timeout=0); // timeout in milliseconds
    34         ssize_t SendMessage(const char* message,size_t message_len,Time timeout=0); // timeout in milliseconds
    35         ssize_t RecvMessage(char* buf,size_t buf_len,Time timeout=0); // timeout in milliseconds
     18namespace flair {
     19namespace core {
     20/*! \class TcpSocket
     21*
     22* \brief Class encapsulating a TCP socket
     23*
     24*/
     25class TcpSocket : public ConnectedSocket {
     26public:
     27  TcpSocket(const Object *parent, const std::string name,
     28            bool blockOnSend = false, bool blockOnReceive = true);
     29  ~TcpSocket();
     30  void Listen(const unsigned int port, const std::string localAddress = "ANY");
     31  TcpSocket *Accept(
     32      Time timeout = 0); // should throw an exception if not a listening socket
     33  bool Connect(const unsigned int distantPort, const std::string distantAddress,
     34               Time timeout = 0); // timeout in milliseconds
     35  ssize_t SendMessage(const char *message, size_t message_len,
     36                      Time timeout = 0); // timeout in milliseconds
     37  ssize_t RecvMessage(char *buf, size_t buf_len,
     38                      Time timeout = 0); // timeout in milliseconds
    3639
    37         uint16_t NetworkToHost16(uint16_t data);
    38         uint16_t HostToNetwork16(uint16_t data);
    39         uint32_t NetworkToHost32(uint32_t data);
    40         uint32_t HostToNetwork32(uint32_t data);
     40  uint16_t NetworkToHost16(uint16_t data);
     41  uint16_t HostToNetwork16(uint16_t data);
     42  uint32_t NetworkToHost32(uint32_t data);
     43  uint32_t HostToNetwork32(uint32_t data);
    4144
    42     private:
    43         int socket; // socket file descriptor
    44         bool blockOnSend;
    45         bool blockOnReceive;
    46         bool isConnected;
    47         unsigned int distantPort;
    48         std::string distantAddress;
    49     };
     45private:
     46  int socket; // socket file descriptor
     47  bool blockOnSend;
     48  bool blockOnReceive;
     49  bool isConnected;
     50  unsigned int distantPort;
     51  std::string distantAddress;
     52};
    5053
    5154} // end namespace core
Note: See TracChangeset for help on using the changeset viewer.