Hello everybody,

This one drives me crazy and I would really appreciate little help.

I'm dealing with TCP/IP socket programming and have the following problem.

When I try to connect to the internet from inside POSE I do successfully get
the connection.

When I try the same from a physical device via a modem I don't get a
connection.

The physical connection successfully dials and gets a connection to my IP
whereas the POSE has a direct (permanent leased line) into the internet
world without the need to dial over an IP.

Would be great if some guru out there is willing to review my "connect" code
and tell me what I'm doing wrong here?


Thanks a lot in advance
Ole




static Boolean ConnectToHost(char* hostname,int port)
/* I have passed in "www.yahoo.com" and port 80*/
{
   struct hostent *host = NULL;
   NetHostInfoBufType AppHostInfo;
   struct sockaddr_in sain;
   int rc = 0;


   host = (struct hostent*)NetLibGetHostByName(AppNetRefnum, hostname,
&AppHostInfo, AppNetTimeout, &h_errno);


   if (!host)
      {
      FrmCustomAlert(altCustom,"Could not connect to host","Sorry"," ");
      return false;
      }

   FrmCustomAlert(altCustom,"Host foundt"," ", " ");

   MemSet(&sain,sizeof(sain),0);


MemMove(&sain.sin_addr,&AppHostInfo.address[1],sizeof(AppHostInfo.address[0]
));
   sain.sin_family = AF_INET;
   sain.sin_port = htons(port);

/* I do have a valid IP Address here. I have cut out this check for better
readability */

   sock =
NetLibSocketOpen(AppNetRefnum,AF_INET,SOCK_STREAM,0,AppNetTimeout,&err);

   if (sock < 0) return false;

   rc = NetLibSocketConnect(AppNetRefnum,
sock,(void*)&sain,sizeof(sain),AppNetTimeout,&err);

   if (rc < 0)
      {
      FrmCustomAlert(altCustom,"can't establish TCP/IP socket connection","
", " ");
      close(sock);
      sock = -1;
      return false;
      }

   FrmCustomAlert(altCustom,"TCP/IP socket connected"," ", " ");

}




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

Reply via email to