This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bind to multicast address fails


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

I try to bind a socket to a multicast address (239.192.202.5). But it fails with an error:
"Cannot assign requested address"

Is this not supported using Cygwin? I've added a simple test program in case someone wants
to verify.

Thanks,
mwarning
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQEcBAEBCAAGBQJTcioBAAoJECHrh56PP4wpXmYH/AyT0e32GL2GxSr5DZexNEkA
lGY3wYUlNkEjkzrFxTNOoTvDTg0nvDD5q9jMH1WoKObbwbhvG27qn3m/iZL4g/HD
DPW935mCEpSp5ryKGUyHBuS28IkLWYhgFZyUF7Uz0zG3VWcdKPo4G/O+/imT7Un4
+2gPJl7wwVsEtmBnxso3EixBBroLIO/w0gd/4b7XEfsInWhe1/GSTdjROTqUh5bY
gmMJIu3kiShGlYdq0c4BcnPgTcJewfunVMLLyl3zoq2KnHof1BqKGP8k6cibuCRo
SRs0meCQX19azuivoX01synqfddB9x/XHbtoiUe3Mxnq/KhUogh5bI5QJgNyGqI=
=HUpc
-----END PGP SIGNATURE-----
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <arpa/inet.h>
#include <sys/socket.h>

int main( int argc, char **argv ) {
	struct sockaddr_in sockaddr;
	if( inet_pton(AF_INET, "239.192.202.5", &sockaddr.sin_addr) != 1 ) {
		printf("parse errorr\n");
		return 1;
	}
	sockaddr.sin_family = AF_INET;
	sockaddr.sin_port = htons(6771);

	int sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );

	socklen_t addrlen= sizeof(struct sockaddr_in);
	if( bind( sock, (struct sockaddr*) &sockaddr, addrlen ) < 0 ) {
		//close( sock );
		printf( "Failed to bind socket to address: %s\n", strerror( errno ) );
		return 1;
	}

	printf("It works.\n");
	//close( sock );
	return 0;
}

Attachment: main.c.sig
Description: PGP signature

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]