public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Moritz Warning <moritzwarning@web.de>
To: cygwin@cygwin.com
Subject: bind to multicast address fails
Date: Tue, 13 May 2014 14:36:00 -0000	[thread overview]
Message-ID: <53722A02.5070201@web.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 851 bytes --]

-----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-----

[-- Attachment #2: main.c --]
[-- Type: text/x-csrc, Size: 706 bytes --]


#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 #3: main.c.sig --]
[-- Type: application/pgp-signature, Size: 287 bytes --]

[-- Attachment #4: Type: text/plain, Size: 218 bytes --]

--
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

             reply	other threads:[~2014-05-13 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 14:36 Moritz Warning [this message]
2014-05-13 14:59 ` Corinna Vinschen
2014-05-13 15:23   ` Moritz Warning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53722A02.5070201@web.de \
    --to=moritzwarning@web.de \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).