mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 10:57:34 +08:00
Add more functions for multicast.
This commit is contained in:
parent
fff2bed41b
commit
e78c53d659
@ -81,6 +81,28 @@ public:
|
||||
bool bind_multicast(const char* addr, const char* iface, int port,
|
||||
int rw_timeout = -1, unsigned flags = 0);
|
||||
|
||||
/**
|
||||
* 当 bind_multicast 成功后,可以调用本方法设置广播包的 TTL 值
|
||||
* @param ttl {int} 该值的范围为 1--255
|
||||
* @return {bool} 设置是否成功
|
||||
*/
|
||||
bool multicast_set_ttl(int ttl);
|
||||
|
||||
/**
|
||||
* 当 bind_multicast 成功后,可以调用本方法设置广播包的本地 IP 地址
|
||||
* @param iface {const char*}
|
||||
* @return {bool} 设置是否成功
|
||||
*/
|
||||
bool multicast_set_if(const char* iface);
|
||||
|
||||
/**
|
||||
* 当 bind_multicast 成功后,可以调用本方法设置离开组播
|
||||
* @param addr {const char*} 广播 IP
|
||||
* @param iface {const char*} 本地 IP
|
||||
* @return {bool} 是否成功
|
||||
*/
|
||||
bool multicast_drop(const char *addr, const char *iface);
|
||||
|
||||
/**
|
||||
* 关闭套接口读操作
|
||||
* @return {bool}
|
||||
|
@ -120,6 +120,36 @@ bool socket_stream::bind_multicast(const char *addr, const char *iface,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool socket_stream::multicast_set_ttl(int ttl)
|
||||
{
|
||||
if (eof_ || stream_ == NULL) {
|
||||
logger_error("Socket not opened yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
return acl_multicast_set_ttl(ACL_VSTREAM_SOCK(stream_), ttl) == 0;
|
||||
}
|
||||
|
||||
bool socket_stream::multicast_set_if(const char *iface)
|
||||
{
|
||||
if (eof_ || stream_ == NULL) {
|
||||
logger_error("Socket not opened yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
return acl_multicast_set_if(ACL_VSTREAM_SOCK(stream_), iface) == 0;
|
||||
}
|
||||
|
||||
bool socket_stream::multicast_drop(const char *addr, const char *iface)
|
||||
{
|
||||
if (eof_ || stream_ == NULL) {
|
||||
logger_error("Socket not opened yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
return acl_multicast_drop(ACL_VSTREAM_SOCK(stream_), addr, iface) == 0;
|
||||
}
|
||||
|
||||
bool socket_stream::shutdown_read(void)
|
||||
{
|
||||
if (stream_ == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user