开发者

Connecting to a multicast server using actual IP and port of the server

I have a multicast server which multicast on an IP 233.1.2.8 on some ports

I need to connect to that server directly using its actual IP do not want to use the broadcast. I want to get actual data it sends on a specific port let say

Multicast Ip  233.1.2.8 port 32334 and 35245
Actual IP 198.122.55.191 port 35366

so i want to read the开发者_如何学运维 data of 35366

I can see that data in CommView.exe but can not read it if i try to connect it connects but no data Thanks


You may want to rethink your question. IP packets have a source and destination address and port, so lets summarise:

  1. You are looking for multicast packets with source port 35366.
  2. Multicast address 233.1.2.8.
  3. Destination port 32334 or 32335.

You will have to open two sockets, one listening to port 32334 and one to 32335, for each socket you will have to the multicast address 233.1.2.8. That gets you a stream of packets from any host, now you have a choice:

  1. Use connect() to restrict to packets from 198.122.55.191.
  2. Use recvmsg() or recvfrom() to read each packet with the source IP address and filter the stream within your application.
  3. Use Source-Specific-Multicast (SSM) and subscribe to multicast address 233.1.2.8 from 198.122.55.191.

The last option usually requires IGMPv3 enabled network and is limited to 232.0.0.0/8 addresses.


Multicast by definition is one-way street: the server sends data to a group, and you subscribe to it.

Connecting to a server cannot be done through UDP, it requires a TCP server actually being there and listening for incoming connections on that particular port. The fact that that port is used for sending out multicast packets doesn't suggest that there's anyone listening on it as well.

If you want to read the data sent from a particular port - then you need to subscribe to all the groups, and analyze the UDP packets (and the IP frame if you have several servers transmitting, to know the origin IP) to see where they're coming from, and filter out the ones that come from the origin you fancy.


You can have a look at this site. It has an example also http://tack.ch/multicast/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜