This is the mail archive of the 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]

support for multicast socket


I'm porting a network protocol (about 50K lines of code) developed in
UNIX into cygwin, and I ran into problems when I want to open a
multicast socket.

When I bind() a network socket to a multicast address/port, I got an
error EADDRNOTAVAIL.  Below is a distilled sample code, sample output,
and my cygwin configuration.

Has anyone been successful in using multicast in cygwin?  If multicast
socket is not currently implemented in cygwin, are there plans to
implement it in the near future?  Any pointer is much appreciated.

Thanks.  Yang-hua

Sample code to open a multicast socket

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <strings.h>
#include <unistd.h>
#include <stdio.h>
#include <netdb.h>

#include <sys/socket.h>
#include <netinet/in.h>	/* sockaddr_in{} and other Internet defns */

int main(int argc, char *argv[]) {
  char *name = "";
  int port = 5000;

  // resolve the IP address
  struct hostent *host;
  if ((host = gethostbyname(name)) == NULL) {
    printf("\nhostname %s not found", name);
    return -1;
  int ip = htonl(*(int *)host->h_addr);

  int fd = socket(AF_INET, SOCK_DGRAM, 0);
  struct sockaddr_in sock;
  bzero((char *)(&sock), sizeof(sock));
  sock.sin_family = AF_INET;
  sock.sin_addr.s_addr = htonl(ip);
  sock.sin_port = htons(port);
  if (bind(fd, (struct sockaddr *)&sock, sizeof(sock)) < 0) {
  } else {
    printf("bind to multicast address OK\n");

Sample output

[yhchu]/cygdrive/c/:{555}:$ ./a.exe
bind: errno EADDRNOTAVAIL triggered

Other relevant information about my cygwin

Cygwin Win95/NT Configuration Diagnostics
Current System Time: Tue Apr 30 18:55:29 2002

Windows NT Ver 4.0 Build 1381 Service Pack 5

Path:	C:\cygwin\usr\local\bin
	c:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT
	c:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
	c:\Program Files\Microsoft Visual Studio\Common\Tools
	c:\Program Files\Microsoft Visual Studio\VC98\bin

SysDir: C:\WINNT\System32
WinDir: C:\WINNT

CYGWIN = `ntsec tty'
HOME = `c:\'
MAKE_MODE = `unix'
PWD = `/cygdrive/h/cmcl-yhchu/yhchu/Code'
USER = `yhchu'

  751k 2002/02/25 C:\cygwin\bin\cygwin1.dll - os=4.0 img=1.0 sys=4.0
                  "cygwin1.dll" v0.0 ts=2002/2/25 11:14
    Cygwin DLL version info:
        DLL version: 1.3.10
        DLL epoch: 19
        DLL bad signal mask: 19005
        DLL old termios: 5
        DLL malloc env: 28
        API major: 0
        API minor: 51
        Shared data: 3
        DLL identifier: cygwin1
        Mount registry: 2
        Cygnus registry name: Cygnus Solutions
        Cygwin registry name: Cygwin
        Program options name: Program Options
        Cygwin mount registry name: mounts v2
        Cygdrive flags: cygdrive flags
        Cygdrive prefix: cygdrive prefix
        Cygdrive default prefix: 
        Build date: Mon Feb 25 11:14:34 EST 2002
        Shared id: cygwin1S3

Unsubscribe info:
Bug reporting:

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