I'm opening and binding a UDP socket (port 0) to my local ip address.  I am 
then sending some stuff to a destination address.  This all appears to be 
working ok.  The problem arises when I try to receive.  If I specify a from 
address and from length in the netlibreceive call i get a netErrInternal, but 
if I put null for the from address and from length everything works ok (at 
least I think it does, because so far i'm only getting netErrWouldBlock (but it 
might be a problem on the other end of the socket).

Here is my code.  Can anyone see why I would be having a problem here?

Err NetListenUDP(NetInfoType *netinfo, PeerInfoType *peerinfo)
{
        Err             err=errNone;
        char            *pBufferBegin=NULL;
        char            *pBufferEnd=NULL;
        UInt16          totalBytesToRead;
        NetSocketAddrINType socketaddr;
//      NetSocketAddrType *socketaddrP = (NetSocketAddrType*) &socketaddr;
        UInt16          socketsize=0;

        
        // We add a byte for null termination.
        totalBytesToRead = netinfo->maxbytestoread + 1;

        // Max size of a handle is 64K - header size
        if (totalBytesToRead > ((64L * 1024) - 16))
        {err=135;}
        
        netinfo->receivestr = MemGluePtrNew(totalBytesToRead);
        MemSet(netinfo->receivestr, totalBytesToRead,'\0');
        pBufferBegin = netinfo->receivestr;
        pBufferEnd = pBufferBegin;
                
        MemSet(&socketaddr, sizeof(socketaddr), 0);
        socketsize = sizeof(socketaddr);

        netinfo->bytesread = 0;
        
        netinfo->bytesread = NetLibReceive(netinfo->netlibrefnum, 
netinfo->socketrefnum, (void *)pBufferEnd, totalBytesToRead, 0, 
 ---> This does NOT work: socketaddrP, &socketsize, -1, &err);
 ---> This DOES work:     NULL, NULL, netinfo->timeout, &err);

<there is more non-important stuff here>
}
-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to