Re: WSASocket FAILS for multicast options..

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: JNH (anonymous_at_discussions.microsoft.com)
Date: 05/24/04


Date: Sun, 23 May 2004 22:38:18 -0700

Way ahead of you there Paul.

Already done the conversion but now I have a different
problem. I can send multicast messages but I can't
receive - not even local loopback....

I'm not sure if this is a driver problem (I saw a
reference to this being a posiblity in a message
somewhere). Is this a real posibility???

I'm using the built in RealTek RTL8139 driver on an x86
based system. However, I have tried the same code on a
PXA255 based system with the same results - send ok but
now receieve...

This is driving me insane - I can do all this on my
desktop PC using WSA or Berkley calls :(

I'll keep trawling the news groups........

Thanks

J

>-----Original Message-----
>Yes, CE supports multicasting using Berkeley calls.
Here's some code that I
>pulled from an IP multicast test I've used on our
devices:
>
> // Initialize Winsock.
> if (WSAStartup (MAKEWORD(1,1), &WSAData) != 0)
> {
> wsprintf (szError, TEXT("WSAStartup failed! Error: %
d"),
> WSAGetLastError ());
> MessageBox (NULL, szError, TEXT("Error"), MB_OK);
> return FALSE;
> }
>
> // Set up the socket. We aren't associated with a
multicast
> // group, after this, but the socket will be ready to be
> // associated.
> if ((Sock = socket (AF_INET, SOCK_DGRAM, 0)) ==
INVALID_SOCKET)
> {
> wsprintf (szError, TEXT("Allocating socket failed!
Error: %d"),
> WSAGetLastError ());
> MessageBox (NULL, szError, TEXT("Error"), MB_OK);
> return FALSE;
> }
>
> // Fill out the local socket's address information.
> local_sin.sin_family = AF_INET;
> local_sin.sin_port = htons (DEST_PORT);
> local_sin.sin_addr.s_addr = htonl (INADDR_ANY);
>
> // Associate the local address with Sock.
> if (bind (Sock,
> (struct sockaddr FAR *) &local_sin,
> sizeof (local_sin)) == SOCKET_ERROR)
> {
> wsprintf (szError, TEXT("Binding socket failed! Error:
%d"),
> WSAGetLastError ());
> MessageBox (NULL, szError, TEXT("Error"), MB_OK);
> closesocket (Sock);
> return FALSE;
> }
>
> // ... The socket is now ready to be associated.
>
>And here's the code that joins a group:
>
> mreq.imr_multiaddr.s_addr = inet_addr( joinIPs );
> mreq.imr_interface.s_addr = INADDR_ANY;
>
> if (setsockopt (Sock,
> IPPROTO_IP,
> IP_ADD_MEMBERSHIP,
> (char FAR *)&mreq,
> sizeof (mreq)) == SOCKET_ERROR)
> {
> wsprintf (szError, TEXT("setsockopt (join) failed!
Error: %d"),
> WSAGetLastError ());
> MessageBox (NULL, szError, TEXT("Error"), MB_OK);
> }
>
>That's about all there is to it...
>
>There are a number of messages in the archives
about "multicast". You can
>search via Google from this link:
>
>http://groups.google.com/groups?
hl=en&group=microsoft.public.windowsce
>
>Paul T.
>
>"JNH" <anonymous@discussions.microsoft.com> wrote in
message
>news:1001601c43ed3$c91e8a60$a501280a@phx.gbl...
>> Paul,
>>
>> Thanks for the reply. Not quite what I expected though.
>>
>> The following isn't aimed at you Paul, just another
rant
>> at MS!
>>
>> If these methods do not 'generally' work, why on earth
>> are they included in the SDK with full Help
>> documentation! Nowhere in the Help files is there any
>> mension of 'not working' in CE! Seems like I've just
>> wasted a lot of time chasing throught this! Thanks
>> Microsoft!
>>
>> One question,does CE support mulicasting using Berkley
>> style calls?
>>
>> JNH
>>
>> >-----Original Message-----
>> >I don't know specifically about WSASocket, but,
>> generally, the WSA socket
>> >calls don't work on Windows CE. You need to use the
>> Berkeley sockets calls
>> >themselves, instead (socket(), bind(), ioctlsocket(),
>> etc.)
>> >
>> >Paul T.
>> >
>> >"JNH" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:f84701c43e37$e0bc0b80$a601280a@phx.gbl...
>> >> Hi,
>> >>
>> >> I've written a small multicast app which works fine
on
>> my
>> >> desktop PC. However, when I ported it to WinCE, eVC
>> 4.0,
>> >> I ran into trouble. According to the WinCE doc's
there
>> >> does not seem to be any difference between Winsock
2.0
>> >> for PC and WinCE.
>> >>
>> >> Here's the code that fails :-
>> >>
>> >> DWORD dwFlags = WSA_FLAG_MULTIPOINT_C_LEAF |
>> >> WSA_FLAG_MULTIPOINT_D_LEAF;
>> >>
>> >> m_pProvider = WSASocket(AF_INET, SOCK_DGRAM,
>> IPPROTO_UDP,
>> >> NULL, 0, dwFlags);
>> >>
>> >> WSAStartup succeeds but the subsequent call to
>> WSASocket
>> >> fails with an error of WSAEINVAL.
>> >>
>> >> Using a value of 0 for dwFlags executes OK but I
cannot
>> >> use the socket for multicast.....
>> >>
>> >> The very same code is fine under Visual Studio.NET
on
>> my
>> >> PC but not on my CE device.... Why????????? :-(
>> >>
>> >> Anyone got any ideas?
>> >>
>> >> Thanks
>> >>
>> >> JNH
>> >>
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>



Relevant Pages

  • Re: WSASocket FAILS for multicast options..
    ... CE supports multicasting using Berkeley calls. ... // Set up the socket. ... We aren't associated with a multicast ... Paul T. ...
    (microsoft.public.windowsce.app.development)
  • Re: Multicast address on CE 5.0
    ... Checked the firewall settings? ... Paul T. ... Multicast and winCE started by shantanu_kush on Jan 25th ... requirements to work around the bug, ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: IOCTL_NDIS_REBIND_ADAPTER and MultiCast
    ... Paul G. Tobey wrote: ... Working on our platform I have noticed that it seems our bound multicast ... - We have a multicast server running ... The user/a program/DHCP server changes the IP address of the interface ...
    (microsoft.public.windowsce.platbuilder)
  • Re: WSASocket FAILS for multicast options..
    ... FD_SET(Sock, &readfs); ... > Way ahead of you there Paul. ... I can send multicast messages but I can't ...
    (microsoft.public.windowsce.app.development)
  • Re: socket question: how to use sendto and recvfrom based on the same multicast address
    ... Why don't you just use the same socket for both send and receive? ... multicast address and receive other data from others on the samd ... closesocket; ... if (setsockopt (sockrcv, ...
    (microsoft.public.windowsce.platbuilder)