1. try run this code on device
2. may be server not worked your packet?
vk> hi all,
vk> i am trying to get data from a the specified URL on PalmOS Simulator5.1 ,
using the NetMgr.h
vk> i have written this code : all functions run successfully and return no
error ..but i am unable to receive data.
vk> // Find the network library
vk> error=SysLibFind("Net.lib", &AppNetRefnum); // returns 0 if no error
vk> if (error==0)
vk> { FldInsert(fldptr1, "could find Net.lib ", 19); }
vk> else
vk> { FldInsert(fldptr1, "could not find Net.lib", 22); }
vk> // Open the network library
vk> error = NetLibOpen(AppNetRefnum, &ifErrs);
vk> if(error==0)
vk> { FldInsert(fldptr1, "could open Net.lib ", 19); }
vk> else
vk> { FldInsert(fldptr1, "could not open Net.lib",22); }
vk> if (ifErrs || (error && error != netErrAlreadyOpen))
vk> {
vk> NetLibClose(AppNetRefnum, false);
vk> return 0 ;
vk> }
vk> MemSet(&destAddr, sizeof(destAddr), 0);
vk> destAddr.family = netSocketAddrINET;
vk> destAddr.port = 80;
vk> hostInfoP = NetLibGetHostByNameAppNetRefnum,"http://www.xyz.com"/*the URL
of my company server comes here*/,hostInfoBufP, AppNetTimeout, &errP);
vk> if(hostInfoP !=0)//no error
vk> {
vk> IPaddressP = (NetIPAddr*)hostInfoBufP->addressList[0];
vk> destAddr.addr = NetNToHL(*IPaddressP);
vk> FldInsert(fldptr1, "gethostbyname successful ", 25);
vk> }
vk> // Open a socket
vk> socket = NetLibSocketOpen(AppNetRefnum, netSocketAddrINET,
netSocketTypeStream, netSocketProtoIPTCP,-1,&error);
vk> /*parameters 1-Network Library,2-Address domain,3-socket
type,4-protocol,5-timeout,6-error result*/
vk> if (error)
vk> { NetLibClose(AppNetRefnum, false);
vk> return 0 ;
vk> }
vk> else{ FldInsert(fldptr1, "socket opened ", 14); }
vk> result = NetLibSocketConnect(AppNetRefnum , socket , (NetSocketAddrType
*)&destAddr , sizeof(destAddr) , AppNetTimeout ,&error);
vk> if (result == 0)
vk> { FldInsert(fldptr1, "socket connects ", 16); }
vk> else
vk> {
vk> FldInsert(fldptr1, "socket does not connect ", 24);
vk> NetLibSocketClose (AppNetRefnum, socket, -1,&error);
vk> NetLibClose(AppNetRefnum, false);
vk> return 0 ;
vk> }
vk> //send
vk> /* i am sending here the URL i want to get data from...am i right here? so
parameter "buf" has the URL*/
vk> /******************i am confused here********/
vk> noOfBytes = NetLibSend(AppNetRefnum,socket , buf , bufLen , 0 , NULL , 0 ,
AppNetTimeout , & error );
vk> if(noOfBytes!=0)
vk> {
vk> FldInsert(fldptr1, "data has been sent ", 19);
vk> }
vk> //recv
vk> size = sizeof(destAddr);
vk> result = NetLibReceive(AppNetRefnum , socket , &bufRecv , size , 0 ,
(NetSocketAddrType *)&destAddr , &size , -1 , &error );
vk> if(result == 0)//no error
vk> {
vk> FldInsert(fldptr1, "data received ", 14);
vk> FldInsert(fldptr, (char*)&bufRecv/*serverResponse*/, 256);
vk> /* i want to insert in a field the data i get from our server i.e bufRecv,
but i get 0 value in this variable*/
vk> /***************not able to receive data here**************/
vk> }else{ FldInsert(fldptr1, "data not received ", 18); }
vk> //close
vk> NetLibSocketClose (AppNetRefnum,socket,-1, &error );
vk> if(error == 0)
vk> { FldInsert(fldptr1, "socket closing ", 15); }
vk> NetLibClose(AppNetRefnum, false);
vk> return true;
vk> }
vk> all those who are working on internet application using NetMgr.h kindly
help...i am unable to find my fault..but there is one for sure..suggestions are
welcomed.
vk> Thanks!
vk> versha
--
Best regards,
Vladimir mailto:[EMAIL PROTECTED]
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/