socket error when calling WSAIoctl

R

Ralph

hi everyone,

i try to develop a test application on my smartphone (Windows Mobile 6
professional)
the application aims to receive mutlicast datagram,
i use windows raw socket :

if (WSAStartup(MAKEWORD(2,2), &wsd) != 0)
{
//printf("WSAStartup() failed: %d\n", GetLastError());
return -1;
}

DWORD dwIoControlCode = SIO_RCVALL_MCAST;
DWORD dwProtocol = IPPROTO_UDP;

SOCKET s = WSASocket(PF_INET, SOCK_RAW, dwProtocol, NULL, 0,
WSA_FLAG_OVERLAPPED);
if (s == INVALID_SOCKET )
{
//printf("WSASocket() failed: %d\n", WSAGetLastError());
return -1;
}

SOCKADDR_IN if0;

if0.sin_family = AF_INET;
if0.sin_port = htons(0);
//192.0.63.36 is my ip adress
if0.sin_addr.s_addr = inet_addr("192.0.63.36");

if (bind(s, (SOCKADDR *)&if0, sizeof(if0)) == SOCKET_ERROR)
{
//printf("bind() failed: %d\n", WSAGetLastError());
return -1;
}

unsigned int optval = 1;
if (WSAIoctl(s, dwIoControlCode, &optval, sizeof(optval),
NULL, 0, &dwBytesRet, NULL, NULL) == SOCKET_ERROR)
{
/*printf("WSAIotcl(%d) failed; %d\n",
dwIoControlCode,WSAGetLastError());
return -1;
}

....

No error when build;
when application is running,
i get an error when application issues WSAIoctl, and the error code is 10022
(WSAEINVAL) according to msdn :
Invalid argument.
Some invalid argument was supplied (for example, specifying an invalid level
to the setsockopt function). In some instances, it also refers to the current
state of the socket—for instance, calling accept on a socket that is not
listening.)

The same code working fine in a standard win32 console application.

My question is :
the option SIO_RCVALL_MCAST is compatible with windows mobile6?
where is the problem else?

thank you for your help or any suggestion
regards
 
C

Chris Tacke, eMVP

This is a Compact Framework group. You might try asking in the
pocketpc.developer or embedded.vc groups.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
P

Paul G. Tobey [eMVP]

I see no sign that Windows CE 5 supports it at all. It's unreferenced in
the WinSock stuff. I'm none too sure about SOCK_RAW, either. What sort of
network adapter is this used with?

Paul T.
 
R

Ralph

I am sorry if this topic is not at right place.

According to msdn on winsock, the method WSAIO is well supported by Windows
CE 5. Otherwise, i would get build error with compiler ARMW4 (in visual
studio 2005)
at the following msdn page,
http://msdn2.microsoft.com/en-us/library/aa916335.aspx
SIO_RCVALL_MCAST is not mentioned as a dwIoControlCode

in fact i don't undestand how the parameter dwIoControlCode is build (I, O,
V, T in the form of the dwIoControlCode),
and why a lot of parameters like SIO_RCVALL_MCAST, SIO_FIND_ROUTE supported
by windows Sockets Version 2 are here missing.


the network adapter that i have used to test, is WIFI, ad hoc

How enable a socket to receive all multicast IP traffic on the network, if
winsock does not support this feature.

thanks for spending time to answer me
 
P

Paul G. Tobey [eMVP]

The call is supported, but that doesn't mean that you can pass any
particular values for the settings to it and expect it to work. As I said,
as far as I can tell, there's no support for that particular code in WinSock
on Windows CE 5.0.

The only way I can think of that would allow you to see all of the multicast
packets would be to build an NDIS intermediate driver, which would see *all*
of the packets, including the multicast ones. That driver would then have
to decide if a given packet was a multicast packet and do the right thing
with it, whatever that is.

Why do you want this capability?

Paul T.
 
R

Ralph

in fact, my smartphone belongs to a small group, i want just receive
multicast packets send by others devices to me. (not ALL the packets on
network)
maybe it is more simple than i've expected.
 
P

Paul G. Tobey [eMVP]

Just use a multi-cast *group* and have each device join the same group.
Everyone in the group will get messages sent to the group and no others.
It's quite simple and we've talked about doing it here before. No extra
drivers needed, everything can be done directly with .NET CF calls, etc.
Much better than your scheme. You can search the archives of this group at:

http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/topics

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top