Re: Multicast Socket for Win CE 4.2 / Pocket PC 2003

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



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.


--






.



Relevant Pages

  • Re: When CString doesnt work
    ... because I would never code something that could not be put into Unicode unless ... >It's tempting to use CStrings throughout the back-end in order to gain ... compiler for their embedded work; they can't afford gcc because they need the fancy ... long as it's small and fast" and, of course, "it only compiles on our platform with our ...
    (microsoft.public.vc.mfc)
  • Re: [OT] Re: wchar_t
    ... but this misses a point: there is an upper limit. ... Unicode doesn't say "21 bits ought to be enough for ... >> of effective character codes, ... > These arguments do not cleanly translate to character sets, ...
    (comp.lang.c)
  • Re: CFile::Read problem ???
    ... As far as the C compiler is concerned, ... you can pretty much always assign a char ... as ASCII and wchar_t as Unicode. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Meanwhile, sounds like the unicode update is coming along ...
    ... half the story when it comes to "supporting" Unicode. ... and he will come/it will just work") is the database. ... good luck trying to store user input data in a non-Unicode database ... I don't think you would sensibly suggest we use a beta compiler to ...
    (borland.public.delphi.non-technical)
  • Re: Software vs hardware floating-point [was Re: What happened ...]
    ... you need about 3x the instruction fetch/decode/scheduling ... Nobody claims that it is a clear win - certainly neither I nor Terje ... Few 'floating-point' codes ... exposing the primitives to the compiler in the P6 era. ...
    (comp.arch)