Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UDP group #480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add UDP group #480

wants to merge 1 commit into from

Conversation

x1244
Copy link

@x1244 x1244 commented Jan 1, 2024

add UDP group IPV4 & IPV6 join group, leave group.

add UDP group IPV4 & IPV6 join group, leave group.
This was referenced Jan 1, 2024
mreq.imr_interface.s_addr = inet_addr(local_host);
return setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const char*)&mreq, sizeof(mreq));
}
HV_INLINE int udp_joingroupv6(int sockfd, const char* group, ULONG interface) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ULONG是windows平台下特有的类型定义,其它平台没有,CI已经报错了

}

// join group
int joinGroup(const char* g){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看了下,就添加了joinGroup、leaveGroup两个方法,其它代码都是拷贝自UdpServer,不如直接加在UdpServer里,没必要单独搞个UdpGroup类了吧

@x1244
Copy link
Author

x1244 commented Jan 5, 2024

这个确实是在UdpServer的基础上添加了joinGroup、leaveGroup两个方法。但是我觉得对于UDP组播来说,接收的不一定是要做为服务器存在,可能它只是建立通道要接收数据,处理并执行,而不是向服务器一样处理后再将数据送出去。
UDP不像TCP一样明显的有服务器-客户端区别,而是更像是生产者-消费者模式,一方负责生产数据,通过UDP点对点或组播将数据发送出去,另一方负责消费数据,接收、处理数据。
所以又起了个名字叫UdpGroup和UdpGroupDest_test,也去掉了UdpServer中直接转发的代码,只是为了使概念更清晰一些,如果说非得必须合并到UdpServer中,我也可以改成那样。
还请您再考虑一下。

@x1244
Copy link
Author

x1244 commented Jan 7, 2024

现在的IPV6组播在linux和mac/ios上没有通过编译,我也用不到,想把它去掉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants