On Tue, 28 Nov 2000, Chris DiPierro wrote:
> I have a funciton that begins like this:
>
> Err IR_Receive (MemPtr estp)
> {
> ExgSocketType *est;
>
> est = (ExgSocketType *) estp;
> ...
>
> }
>
> Which is called from PilotMain as follows:
> if (cmd == sysAppLaunchCmdExgReceiveData) {
> IR_Receive(cmdPBP);
> return 0;
> }
>
> Now, if I set POSE or a real device into IR loopback, all works great.
>
> But if I use 2 devices, the ask dialog comes up, I say 'Yes', but
> est->length becomes 0 and I just bail there. Doesn't matter if my app is
> currently running or not.
>
> Is there something I'm missing here? I thought what I've done above is
> correct...
>
>
You need to call ExgAccept() on the socket. Try this:
Char buf[BIGBUF];
if (cmd == sysAppLaunchCmdExgReceiveData) {
IR_Receive((ExgSocketPtr) cmdPBP, buf);
return 0;
}
Int IR_Receive(ExgSocketPtr sock, Char *buf)
{
Int len, tot;
Err err = 0;
tot = 0;
ExgAccept(sock);
while (!err && (len = ExgReceive(sock, buf + tot, SMALLBUF, &err)) {
if (!err && len) tot += len;
}
ExgDisconnect(sock);
return tot;
}
error handling and other niceties are left as an exercise :)
also, make sure BIGBUF is big enough to receive all of the potential data, or
add in handling code for overflowing the buffer.
Simon.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/