#ifndef POLYGUN_NETWORK_UDP_SOCKET_HPP
#define POLYGUN_NETWORK_UDP_SOCKET_HPP

#include <string>
#if defined(__unix__)
#include <netinet/in.h>
#endif

namespace polygun::network {
	class NetworkPacket;

	class UDPSocket {
	public:
		UDPSocket();
		~UDPSocket();

		void connect(const std::string& ip, unsigned short port);
		void bind(unsigned short port);
		bool send(const UDPSocket& target, const NetworkPacket& packet) const;
		bool recv(const UDPSocket& from, NetworkPacket& packet);
		bool has_incoming_data() const;
		void close();

	private:
		int m_fd;
		struct sockaddr_in m_addr;
	};
}

#endif
