Marc, Good luck finding working examples on Netlib. My company is trying to decide which device to support for our mobile workforce and I am trying to develop a simple demo showing data exchange with a backend system with PocketPC and Palm. PocketPC version was up and running in less than two days using SOAP (HTTP/XML combo). It has been two weeks now and I am still struggling with Netlib and haven't even thought about how to write an XML parser (since there doesn't seem to be any for Palm). Going into this exercise I was confident we would go with Palm but I believe our developers would just have too much trouble getting up to speed due to the near complete lack of code snippets on the internet. I looked at the other posts to your comment and personally didn't find either to be too helpful (Palm example doesn't actually show a working example and the O'Reilly example appears to use datatypes that aren't compatible with PalmOS 3.5... at least not for a newbie like me). I like the Palm devices and hope they can get more examples up for the corporate developer before MS takes over this market too (search for NetLibReceive in Yahoo netted 10 results, less than 40 on google, and a mere 4 on Palm's own page).
Anyway... here is some code that does what you asked for but not much more... Basically it will successfully open a socket and send a string to another computer (I used a test bench found at http://www.vbip.com/winsock-api/listen-accept/listen-accept-01.asp to verify that a connection was established and that data was recieved by the server. I have also sent data back to the Palm and believe that it is arriving due to the number of bytes 'read' from the port. Unfortunately, I am now struggling with string manipulation and haven't been able to actually see the data that was received. If you crack this nut I would be happy to hear from you (I would be satisfied just to see the text show up in an alert box at this point). My environment consists of: -Windows 2000 -Metrowerks Codewarrior 8.0 demo version -Palm OS Emulator As others have said, you will probably need to right click on the emulator face and goto Settings --> Properties and select 'Redirect Netlib calls to host TCP/IP'. I believe you need to add a couple of headers shown below and then a couple of global variables also shown below. i called the SocketConnect method during startup with the call 'SocketConnect();' and display results in an alert box with 2 wildcards. To validate that a connection was established I 'bound' the testbench socket to port 555 of my local IP address (using IPConfig /all from the command line) and then used these settings with the PALM and it connected successfully. I then changed the IP address to one of our production servers, set the port to 80, and used the string "GET /tcpip.asp HTTP/1.0\r\n\r\n" to retrieve the 'tcpip.asp' test page that we made. As I said above, I am pretty sure the data is actually getting to the Palm because when I change the page on the server the number of bytes 'read' changes. Unfortunately my string manipulation skills won't let me actually view the data. I would be happy to hear from you if this works and if you can actually see the results sent back to the client. Lance // Header files #include <PalmOS.h> #include <Sys_Socket.h> #include <NetMgr.h> // Global variables Err errno; UInt16 AppNetRefnum; Int32 AppNetTimeout; Int16 mySockFd; static void SocketConnect() { Int16 i; UInt16 myHowMany; UInt8* textP; UInt16* sizeP; struct sockaddr_in mySockAddr; static Char sText [255] = ""; Char strX; char last_read=0; const char kLinefeed = 10; Int16 bytesread; Err myifErr; Int32 plongAddress; Int16 pintClientSize; Err myErr; AppNetTimeout = SysTicksPerSecond() * 10; myErr = SysLibFind("Net.lib", &AppNetRefnum); if (myErr){ FrmCustomAlert(1000, "Net Library Failed to initialize", "", NULL); }; myErr = NetLibOpen(AppNetRefnum, &myifErr); if (myErr){ FrmCustomAlert(1000, "Failed to open Net Library", "", NULL); }; mySockFd = NetLibSocketOpen(AppNetRefnum, AF_INET, SOCK_STREAM, 0, AppNetTimeout, &errno); plongAddress = NetLibAddrAToIN(AppNetRefnum, "127.0.0.1"); // <---------------------------You will need to put an IP address here mySockAddr.sin_family = AF_INET; mySockAddr.sin_port = 80; mySockAddr.sin_addr.s_addr = plongAddress; pintClientSize = sizeof(mySockAddr); myErr = connect(mySockFd, &mySockAddr, sizeof(mySockAddr)); if (myErr) { FrmCustomAlert(1000, "Connection Failed", "", NULL); } myHowMany = NetLibSend(AppNetRefnum, mySockFd, &"GET /tcpip.asp HTTP/1.0\r\n\r\n", strlen("GET /tcpip.asp HTTP/1.0\r\n\r\n"), 0, 0, 0, AppNetTimeout, &errno); FrmCustomAlert(1000, "Sending bytes", StrIToA(&strX,myHowMany), ""); myHowMany = NetLibReceive(AppNetRefnum, mySockFd, textP, *sizeP, 0, NULL, 0, AppNetTimeout, &errno); } "Marc Ouellette" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED].; > > Hi All, > > Does anyone have any quick samples on just making the connection to the > server with netlib. I am a real newbie at palm program and would like to > know the steps. All I have to do is make a connection to a sertain port on a > server and send a strings. > > Thanks, > Marc > > > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
