Windows and multicast #266

Closed
opened 2026-01-29 16:39:25 +00:00 by claunia · 1 comment
Owner

Originally created by @cfsmp3 on GitHub (Jan 25, 2017).

Originally assigned to: @Izaron on GitHub.

We're hitting exactly this problem:

http://stackoverflow.com/questions/6140734/cannot-bind-to-multicast-address-windows

Suppose this real scenario: We have a number of multicast streams. They are in different addresses, for example

239.168.100.1:5000
239.168.100.2:5000

This means that we cannot just bind to any interface (0.0.0.0) on port 5000, because then we get things mixed up.

The obvious solution is to bind to the complete IP+port. In linux this works fine, but Windows says "IP address not available", i.e. you cannot bind the socket to the multicast IP address.

For now (because I needed to get it working) I've done the following:

#if _WIN32
	// Doesn't seem correct, if there's more than one multicast stream with the same
	// port number we get corruption - IP address needs to be specified, but 
	// in Windows we get an error 10049 (cannot bind).
	// http ://stackoverflow.com/questions/6140734/cannot-bind-to-multicast-address-windows
	servaddr.sin_addr.s_addr = htonl(IN_MULTICAST(addr) ? INADDR_ANY : addr);
#else
	servaddr.sin_addr.s_addr = htonl(addr);
#endif

Which solves the problem in linux and leaves Windows behaving as before.

It's definitely not the right solution.
http://stackoverflow.com/questions/10692956/what-does-it-mean-to-bind-a-multicast-udp-socket

I'm assigning this to @Izaron since he did the last network changes if I recall correctly.

Originally created by @cfsmp3 on GitHub (Jan 25, 2017). Originally assigned to: @Izaron on GitHub. We're hitting exactly this problem: http://stackoverflow.com/questions/6140734/cannot-bind-to-multicast-address-windows Suppose this real scenario: We have a number of multicast streams. They are in different addresses, for example 239.168.100.1:5000 239.168.100.2:5000 This means that we cannot just bind to any interface (0.0.0.0) on port 5000, because then we get things mixed up. The obvious solution is to bind to the complete IP+port. In linux this works fine, but Windows says "IP address not available", i.e. you cannot bind the socket to the multicast IP address. For now (because I needed to get it working) I've done the following: ``` #if _WIN32 // Doesn't seem correct, if there's more than one multicast stream with the same // port number we get corruption - IP address needs to be specified, but // in Windows we get an error 10049 (cannot bind). // http ://stackoverflow.com/questions/6140734/cannot-bind-to-multicast-address-windows servaddr.sin_addr.s_addr = htonl(IN_MULTICAST(addr) ? INADDR_ANY : addr); #else servaddr.sin_addr.s_addr = htonl(addr); #endif ``` Which solves the problem in linux and leaves Windows behaving as before. It's definitely not the right solution. http://stackoverflow.com/questions/10692956/what-does-it-mean-to-bind-a-multicast-udp-socket I'm assigning this to @Izaron since he did the last network changes if I recall correctly.
claunia added the GCI19 label 2026-01-29 16:39:25 +00:00
Author
Owner

@cfsmp3 commented on GitHub (Jan 25, 2017):

GSoC: This issue gives 2 qualification points.

@cfsmp3 commented on GitHub (Jan 25, 2017): GSoC: This issue gives 2 qualification points.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/ccextractor#266