* multicast
@ 1997-03-19 18:13 Bruce D. McLeod
0 siblings, 0 replies; 5+ messages in thread
From: Bruce D. McLeod @ 1997-03-19 18:13 UTC (permalink / raw)
To: gnu-win32
This seems to be due to the mapping of IP_ADD_MEMBERSHIP to 35
in cygwin32/socket.h as opposed to 5 in winsock.h. I hardcoded
the option at 5, and it works fine.
Bruce
>Date: Wed, 19 Mar 1997 11:16:14 -0500
>To: gnu-win32@cygnus.com
>From: "Bruce D. McLeod" <b.mcleod@opengroup.org>
>Subject: multicast
>
>Has anyone successfully used multicast using the sys/sockets.h version
>of the network stuff? I am getting "This option is unsupported"
>for the setsockopt:
>
> err = setsockopt( gListener, IPPROTO_IP, IP_ADD_MEMBERSHIP,
> (char *) &multiStruct, sizeof(multiStruct) );
>
>Bruce
>
>The full code...
>
>
>#include <sys/socket.h>
>#include <netinet/in.h>
>#include <netdb.h>
>#include <stdio.h>
>
>#define PANIC() printf("panic\n"); exit(1);
>#define ASSERT( x ) if ( (x) == 0 ) { PANIC(); }
>
>const static int gMyPort = 5500;
>const static char* gMyMultiIp = "225.1.1.88";
>int gListener;
>
>main( int argc, char **argv )
>{
> if (argc > 1) {
> struct sockaddr_in localAddr;
> int err, value;
> struct ip_mreq multiStruct;
> char hostName[200];
> struct hostent* myHostent;
>
> // Set up listening socket.
> gListener = socket( AF_INET, SOCK_DGRAM, 0 );
> ASSERT( gListener != -1 );
>
> value = 1;
> err = setsockopt( gListener, SOL_SOCKET, SO_REUSEADDR,
> (char *) &value, sizeof(value) );
> ASSERT( err != -1 );
>
> err = gethostname( hostName, 200 );
> ASSERT( err != -1 );
> myHostent = gethostbyname( hostName );
> ASSERT( myHostent != NULL );
>
> localAddr.sin_family = AF_INET;
> localAddr.sin_addr.s_addr = *((long *) myHostent->h_addr_list[0]);
> localAddr.sin_port = htons( gMyPort );
>
> err = bind( gListener, (struct sockaddr *) &localAddr,
sizeof(localAddr) );
> ASSERT( err != -1 );
>
> multiStruct.imr_multiaddr.s_addr = inet_addr( gMyMultiIp );
> multiStruct.imr_interface.s_addr = *((long *) myHostent->h_addr_list[0]);
> err = setsockopt( gListener, IPPROTO_IP, IP_ADD_MEMBERSHIP,
> (char *) &multiStruct, sizeof(multiStruct) );
> if (err == -1) perror("setsockopt failed");
> ASSERT( err != -1 );
>
> for (;;) {
> static const int bufsize = 200;
> char buf[bufsize];
> struct sockaddr fromAddr;
> int fromAddrLen, bytes;
>
> printf( "MultiTest: waiting for data\n" );
>
> fromAddrLen = sizeof(fromAddr);
> bytes = recvfrom( gListener, buf, bufsize, 0,
> &fromAddr, &fromAddrLen );
> ASSERT( bytes >= 0 );
>
> if (bytes == 0) {
> printf( "MultiTest: disconnect received\n" );
> close( gListener );
> return 1;
> }
>
> printf( "MultiTest: msg received: %s\n", buf );
> }
> } else {
> static const char msg[] = "Hello world.";
> struct sockaddr_in remoteAddr;
> int bytes;
>
> int s = socket( AF_INET, SOCK_DGRAM, 0 );
> ASSERT( s != -1 );
>
> remoteAddr.sin_family = AF_INET;
> remoteAddr.sin_port = htons( gMyPort );
> remoteAddr.sin_addr.s_addr = inet_addr( gMyMultiIp );
>
> bytes = sendto( s, msg, strlen( msg ) + 1, 0,
> (struct sockaddr *) &remoteAddr, sizeof(remoteAddr) );
> ASSERT( bytes == (int) strlen( msg ) + 1 );
> printf("MultiTest: msg sent\n");
>
> close( s );
> }
>
> return 0;
>}
>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* multicast
1999-10-08 7:08 multicast Laszlo Vecsey
@ 1999-10-31 19:54 ` Laszlo Vecsey
0 siblings, 0 replies; 5+ messages in thread
From: Laszlo Vecsey @ 1999-10-31 19:54 UTC (permalink / raw)
To: cygwin
I tried a straitforward port of mash.c (monstermash.c, multicast tunneling
program), and ran into a problem when it tries to join a group. I'm trying
to tunnel the sap.mcast.net group of 224.2.127.254. The winsock error I'm
getting is 10022, which means "No error", I think. Has anyone gotten this
to work?
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* multicast
@ 1999-10-08 7:08 Laszlo Vecsey
1999-10-31 19:54 ` multicast Laszlo Vecsey
0 siblings, 1 reply; 5+ messages in thread
From: Laszlo Vecsey @ 1999-10-08 7:08 UTC (permalink / raw)
To: cygwin
I tried a straitforward port of mash.c (monstermash.c, multicast tunneling
program), and ran into a problem when it tries to join a group. I'm trying
to tunnel the sap.mcast.net group of 224.2.127.254. The winsock error I'm
getting is 10022, which means "No error", I think. Has anyone gotten this
to work?
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: multicast
1997-03-19 10:28 multicast Bruce D. McLeod
@ 1997-03-19 23:02 ` Chin Chee-Kai
0 siblings, 0 replies; 5+ messages in thread
From: Chin Chee-Kai @ 1997-03-19 23:02 UTC (permalink / raw)
To: Bruce D. McLeod; +Cc: gnu-win32
Interesting trial you have there. I ran your code as-is on
an SGI (which supports multicast send/receive) and didn't
manage to get multicasting. Finally, I got a line fixed and
got it running on SGI doing multicast sending/receiving.
Later, I got it compiled on Win95 and tried on the
combination SGI-receiving/Win95-sending and got the right result.
Unfortunately, Win95 doesn't allow me to emulate being on
a multicast network (using Control-Panel to set another
IP Adapter to 224.x.x.x address), so I can't try the reverse
combination (Win95-receiving/SGI-sending).
Basically, the change is:
localAddr.sin_addr.s_addr = *((long *) myHostent->h_addr_list[0]);
to
localAddr.sin_addr.s_addr = inet_addr(gMyMultiIp);
The idea is that you need to bind to the multicasting
network address, logically as if this host also has a
local address at this multicasting address. The idea
is much like "localhost" (127.0.0.1) being the address
of the local machine. So if your machine+OS+network card
supports multicasting, then the Class D networks starting
from "224.0.0.0" are also logically the address of the
local machine.
The operation is not so clear if you first bind a socket
to a unicast IP address (the one returned by gethostbyname())
and subsequently add multicast membership to a unicast-recipient
socket using setsockopt(... IP_ADD_MEMBERSHIP...)
(by which time bind() would have already named a socket with
a unicast address. On the other hand, setsockopt() could
undo the semantics of bind() on seeing IP_ADD_MEMBERSHIP
so that the socket can be a recipient of a multicast network.
This is implementation dependent [It's not that clean IMHO].)
Chin Chee-Kai (Last, First)
Internet Email-ID: cheekai@gen.co.jp
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
* multicast
@ 1997-03-19 10:28 Bruce D. McLeod
1997-03-19 23:02 ` multicast Chin Chee-Kai
0 siblings, 1 reply; 5+ messages in thread
From: Bruce D. McLeod @ 1997-03-19 10:28 UTC (permalink / raw)
To: gnu-win32
Has anyone successfully used multicast using the sys/sockets.h version
of the network stuff? I am getting "This option is unsupported"
for the setsockopt:
err = setsockopt( gListener, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *) &multiStruct, sizeof(multiStruct) );
Bruce
The full code...
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#define PANIC() printf("panic\n"); exit(1);
#define ASSERT( x ) if ( (x) == 0 ) { PANIC(); }
const static int gMyPort = 5500;
const static char* gMyMultiIp = "225.1.1.88";
int gListener;
main( int argc, char **argv )
{
if (argc > 1) {
struct sockaddr_in localAddr;
int err, value;
struct ip_mreq multiStruct;
char hostName[200];
struct hostent* myHostent;
// Set up listening socket.
gListener = socket( AF_INET, SOCK_DGRAM, 0 );
ASSERT( gListener != -1 );
value = 1;
err = setsockopt( gListener, SOL_SOCKET, SO_REUSEADDR,
(char *) &value, sizeof(value) );
ASSERT( err != -1 );
err = gethostname( hostName, 200 );
ASSERT( err != -1 );
myHostent = gethostbyname( hostName );
ASSERT( myHostent != NULL );
localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = *((long *) myHostent->h_addr_list[0]);
localAddr.sin_port = htons( gMyPort );
err = bind( gListener, (struct sockaddr *) &localAddr,
sizeof(localAddr) );
ASSERT( err != -1 );
multiStruct.imr_multiaddr.s_addr = inet_addr( gMyMultiIp );
multiStruct.imr_interface.s_addr = *((long *) myHostent->h_addr_list[0]);
err = setsockopt( gListener, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char *) &multiStruct, sizeof(multiStruct) );
if (err == -1) perror("setsockopt failed");
ASSERT( err != -1 );
for (;;) {
static const int bufsize = 200;
char buf[bufsize];
struct sockaddr fromAddr;
int fromAddrLen, bytes;
printf( "MultiTest: waiting for data\n" );
fromAddrLen = sizeof(fromAddr);
bytes = recvfrom( gListener, buf, bufsize, 0,
&fromAddr, &fromAddrLen );
ASSERT( bytes >= 0 );
if (bytes == 0) {
printf( "MultiTest: disconnect received\n" );
close( gListener );
return 1;
}
printf( "MultiTest: msg received: %s\n", buf );
}
} else {
static const char msg[] = "Hello world.";
struct sockaddr_in remoteAddr;
int bytes;
int s = socket( AF_INET, SOCK_DGRAM, 0 );
ASSERT( s != -1 );
remoteAddr.sin_family = AF_INET;
remoteAddr.sin_port = htons( gMyPort );
remoteAddr.sin_addr.s_addr = inet_addr( gMyMultiIp );
bytes = sendto( s, msg, strlen( msg ) + 1, 0,
(struct sockaddr *) &remoteAddr, sizeof(remoteAddr) );
ASSERT( bytes == (int) strlen( msg ) + 1 );
printf("MultiTest: msg sent\n");
close( s );
}
return 0;
}
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-10-31 19:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-19 18:13 multicast Bruce D. McLeod
-- strict thread matches above, loose matches on Subject: below --
1999-10-08 7:08 multicast Laszlo Vecsey
1999-10-31 19:54 ` multicast Laszlo Vecsey
1997-03-19 10:28 multicast Bruce D. McLeod
1997-03-19 23:02 ` multicast Chin Chee-Kai
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).