/* Blinker
   Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
   Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
   a blinkenarea.org project */

#ifndef UDP6SOCK_H
#define UDP6SOCK_H

#include <winsock2.h>
#include <string>

#include "Io.h"
#include "Udp6Addr.h"

namespace Blinker {

/**
 * @brief UDP v6 socket
 *
 * UDP v6 socket in non-blocking mode with address re-usage enabled
 */
class Udp6Sock: public Io
{
public:
  /// constructor
  Udp6Sock();

  /// destructor
  ~Udp6Sock();

private:
  /// copy constructor disabled
  Udp6Sock(const Udp6Sock &that);

  /// assignment operator disabled
  const Udp6Sock & operator=(const Udp6Sock &that);

public:
  /**
   * @brief get address the socket is bound to
   * @param[out] addr local addess the socket is bound to
   * @return if local address could be obtained
   */
  bool getAddr(Udp6Addr &addr);

  /**
   * @brief bind socket
   * @param[in] addr local address to bind to
   * @return if binding succeeded
   */
  bool bind(const Udp6Addr &addr);

  /**
   * @brief send to socket
   * @param[in] data data to send in message
   * @param[in] addr address the message should be sent to
   * @return if the message could be sent
   */
  bool send(const std::string &data, const Udp6Addr &addr);

  /**
   * @brief receive from socket
   * @param[out] data data in received message
   * @param[out] addr address the message has been received from
   * @return if a message has been received
   */
  bool recv(std::string &data, Udp6Addr &addr);

}; // class UdpSock

} // namespace Blinker

#endif // #ifndef UDP6SOCK_H

