Initial
This commit is contained in:
82
socket/ipmcast.hpp
Normal file
82
socket/ipmcast.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
#ifndef _SOCKET_IPMULTICAST_HPP_
|
||||
#define _SOCKET_IPMULTICAST_HPP_
|
||||
#ifndef _SOCKET_SOCKET_HPP_
|
||||
#include <socket/socket.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class IPMReq : private ip_mreq
|
||||
{
|
||||
public:
|
||||
IPMReq();
|
||||
virtual ~IPMReq();
|
||||
operator ip_mreq &(void);
|
||||
InternetAddress multicastAddress(void)const;
|
||||
void multicastAddress(const InternetAddress &multicastAddress);
|
||||
InternetAddress localAddress(void)const;
|
||||
void localAddress(const InternetAddress &localAddress);
|
||||
static int length(void);
|
||||
String toString(void)const;
|
||||
private:
|
||||
};
|
||||
|
||||
inline
|
||||
IPMReq::IPMReq()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
IPMReq::~IPMReq()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
IPMReq::operator ip_mreq &(void)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress IPMReq::multicastAddress(void)const
|
||||
{
|
||||
return InternetAddress(ip_mreq::imr_multiaddr);
|
||||
}
|
||||
|
||||
inline
|
||||
void IPMReq::multicastAddress(const InternetAddress &multicastAddress)
|
||||
{
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b1=multicastAddress.b1();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b2=multicastAddress.b2();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b3=multicastAddress.b3();
|
||||
ip_mreq::imr_multiaddr.S_un.S_un_b.s_b4=multicastAddress.b4();
|
||||
}
|
||||
|
||||
inline
|
||||
InternetAddress IPMReq::localAddress(void)const
|
||||
{
|
||||
return InternetAddress(ip_mreq::imr_interface);
|
||||
}
|
||||
|
||||
inline
|
||||
void IPMReq::localAddress(const InternetAddress &localAddress)
|
||||
{
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b1=localAddress.b1();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b2=localAddress.b2();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b3=localAddress.b3();
|
||||
ip_mreq::imr_interface.S_un.S_un_b.s_b4=localAddress.b4();
|
||||
}
|
||||
|
||||
inline
|
||||
String IPMReq::toString(void)const
|
||||
{
|
||||
return String("mcast:")+multicastAddress().toString()+String(", local:")+localAddress().toString();
|
||||
}
|
||||
|
||||
inline
|
||||
int IPMReq::length(void)
|
||||
{
|
||||
return sizeof(ip_mreq);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user