I have a problem with multicast/sockets that I cannot solve.
If I run 2 applications on 2 different PCs on port 4000 and ip 225.0.0.1, everything works great. If I try to JoinMulticastGroup 225.0.0.2 port 5000, it doesn't work because, if I've properly understo开发者_Go百科od, if you start the applications with port 4000, you can use only that port.
Now, as we need to run several applications that communicate via multicast on the same PC and I cannot join groups with other ports, I have to start all the applications on the same port but it seems to be impossible. I've already tried to set the SO_REUSEADDR socket option, but it didn't help.
Any help would be greatly appreciated.
> "if you start the applications with port 4000, you can use only that port."
Not quite: if you connect your socket to port 4000 then you cannot connect the same socket to a different port (unless you reuse the socket, which is a different story and it still doesn't solve your issue). However, you can create multiple sockets within your application and each one can joint a different multicast, but you cannot have one socket change the port it's connected to.
It would also help if you provide us with a simple (sscce compliant) example of what you're trying to do so we can specifically point out where you're going wrong.
Ok, thanks for the help but I think I've understood where the problem is. I've fixed the problem of running multiple applications adding SO_REUSEADDR before the bind in the jrtblib that the plugin I've done is using. Now it works because I had to add the option also to the rtcp socket, not only to the rtp one. Another problem is that I have misunderstood the use of the jrtplib. I was trying to use the same client to send and receive but this is not how the jrtplib is supposed to work. Using the same client to send and receive, I was forced to use the same port in all the clients and this created problems. Now that I start a dedicated plugin for sending and another one for receiving, everything works like a charm.
精彩评论