Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Tue, 23 May 2006 14:03:41 -0700
Whenever you see "cannot convert unsigned short * to char *", you should
automatically think to yourself "Unicode" (or yell it out, if your coworkers
don't mind). In this case, the method you are calling does *not* expect a
Unicode (two-byte per character), string, but that's what you are trying to
pass it. It wants an ordinary ANSI (one-byte per character), string.
On the desktop, you typically are *not* compiling for Unicode; on Windows
CE, you *always* are.
Paul T.
"bpriya" <bpriya@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A83146E8-5762-42E5-8CB7-B42C5A0284BF@xxxxxxxxxxxxxxxx
Thanks for the response. Actually is a simple compile error, eVC++
compiler
does
not take strGroupIP as a string, and the error: cannot convert parameter 1
from 'const unsigned short *' to 'const char *. I have eVC++ 4.0 compiler.
I
don't
know why the compiler treats 'LPCTSTR strGroupIP' as 'const unsigned short
*'.
One important point I want to make is that if the codes which run ok on
desktop
can also be ported for Win CE 4.2 environment. I have past experience that
the
MFC codes that run on desktop don't necessarily work on WinCE MFC
environment.
Rgds,
-bpriya
BOOL CMulticastSocket::CreateReceivingSocket(LPCTSTR strGroupIP, UINT
nGroupPort)
{
/* Create socket for receiving packets from multicast group */
if(!Create(nGroupPort, SOCK_DGRAM, FD_READ))
return FALSE;
BOOL bMultipleApps = TRUE;
SetSockOpt(SO_REUSEADDR, (void*)&bMultipleApps, sizeof(BOOL), SOL_SOCKET);
/* Fill m_saHostGroup_in for sending datagrams */
memset(&m_saHostGroup, 0, sizeof(m_saHostGroup));
m_saHostGroup.sin_family = AF_INET;
m_saHostGroup.sin_addr.s_addr = inet_addr(strGroupIP);
m_saHostGroup.sin_port = htons((USHORT)nGroupPort);
/* Join the multicast group */
m_mrMReq.imr_multiaddr.s_addr = inet_addr(strGroupIP); /* group addr */
m_mrMReq.imr_interface.s_addr = htons(INADDR_ANY); /* use default */
if(setsockopt(m_hSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char FAR
*)&m_mrMReq, sizeof(m_mrMReq)) < 0)
return FALSE;
return TRUE;
}
"voidcoder" wrote:
The description of your problem is quite vague. What
errors do you get?
"bpriya" <bpriya@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:575FF536-C99F-47E2-8A45-1569202F871C@xxxxxxxxxxxxxxxx
Hi All,
We're developing applications using Embedded VC++ 4.0 on Win CE 4.2
platform
with target of Pocket PC 2003. I'm trying to develop multicast socket
datagram
using CAsyncSocket as the base class. I downloaded sample code from web
site
using CAsyncSocket which runs well on desktop PC. Does anybody know
that this
should work also on Win CE 4.2 ? I tried to port this code to my
application
on Win
CE 4.2 but it does not even compile correctly. Maybe I should make some
changes
but I don't want to waste time if it is not going to work later on.
Appreciate any
inputs.
Thanks for your kind responses.
-priyanto.
--
.
- Follow-Ups:
- Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- From: bpriya
- Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- References:
- Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- From: voidcoder
- Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- From: bpriya
- Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- Prev by Date: Re: PSM
- Next by Date: Re: SetWindowsHookEx, just one question;
- Previous by thread: Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- Next by thread: Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003
- Index(es):
Relevant Pages
|