在Linux的同一套接字上接收来自不同组的多播数据 [英] Receiving multicast data from different groups on the same socket in linux

查看:84
本文介绍了在Linux的同一套接字上接收来自不同组的多播数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想在Linux C程序中从239.1.2.3:20000以及239.4.5.6:20001接收数据.我可以只用一个插座来做吗?

Say I want to receive data from 239.1.2.3:20000 and also from 239.4.5.6:20001 in a linux C program. Can I do so with just one socket?

我当然可以使用IP_ADD_MEMBERSHIP setsockopt选项在套接字上加入多个组,但是,由于端口不同,因此我不确定是否可以通过某种方式绑定到两个端口"

I can of course join multiple groups on the socket using the IP_ADD_MEMBERSHIP setsockopt option, but, since the ports are different, I am not sure if it is possible to somehow "bind to both ports"

推荐答案

不,您不能将套接字绑定到2个端口,每个端口需要一个套接字.

No, you can't bind a socket to 2 ports, you need a socket per port.

这篇关于在Linux的同一套接字上接收来自不同组的多播数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆