can anybody tell me why the following code doesnt
work on PalmOS5? i'm testing it on the simulator.
The same code works fine on the M505 emulator.

I'm using "localhost" as the server and port = "12345"

on the real OS5 device it errors out in the "Listen" api
if it put in a real ip address.

thanks





Int16 setup_server(char *server, char *port)
{
 UInt32 non_block = 1;
 NetSocketRef socket = 0;
    NetHostInfoPtr phe;
    NetHostInfoBufType AppHostInfo;
    Boolean nameresolved = false;
    short i1;

    MemSet((char *) &Address, sizeof(Address), 0);
 Address.family = netSocketAddrINET;
 Address.port = NetHToNS(StrAToI(port));
 Address.addr = 0L;


 socket = NetLibSocketOpen(AppNetRefnum, netSocketAddrINET,
       netSocketTypeStream, 0, AppNetTimeout, &errno);
 if (socket == -1)
  return -1;


    if ((Address.addr = NetLibAddrAToIN(AppNetRefnum, server)) == -1) {
        if ((phe = NetLibGetHostByName(AppNetRefnum, server, &AppHostInfo,
            AppNetTimeout, &errno)) != 0) {
            for (i1=0; i1 < netDNSMaxAddresses; i1++) {
                if (phe->addrListP[i1] != NULL) {
                    if (*phe->addrListP[i1] != '\0') {
                        MemMove((char *) &Address.addr,
                            (char *) phe->addrListP[i1], phe->addrLen);
                        nameresolved = true;
                        break;
                    }
                }
            }
        }
        if (!nameresolved) {
            NetLibSocketClose(AppNetRefnum, socket, AppNetTimeout, &errno);
            return -3;
        }

    }

 if (NetLibSocketBind(AppNetRefnum,socket,(struct  NetSocketAddrType *)
&Address, sizeof(Address), AppNetTimeout, &errno) == -1)
 {
        NetLibSocketClose(AppNetRefnum, socket, AppNetTimeout, &errno);
  return -2;
 }

 if (NetLibSocketListen(AppNetRefnum, socket, 1, AppNetTimeout, &errno)
== -1)
 {
        NetLibSocketClose(AppNetRefnum, socket, AppNetTimeout, &errno);
  return -5;
 }


 return socket;
}




-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to