21.08.2015 Views

Pro

May 1998 - JeffLuther.net

May 1998 - JeffLuther.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

getFirst( ) method should reset an internal index andreturn the first row of the result set; the getNext( ) methodshould increase the index and return the next row in theresult set. The Remote Object “TableLoader” is includedin the server test code. See Figure 2 for the test client resultwith the jvm, Figure 3 for the same code in an applet, andFigure 4 for the server transactions log.The test applet (included with the sample code)connects and tells the server to load the result set onlyonce, when the browser loads it, and retrieves all the rowseach time it needs to repaint its window. This approachcauses the applet to generate network traffic each time thewindow needs to be repainted. It would be better toconnect, load all the rows, and disconnect when theapplet gets loaded the first time and then use the localstorage to refresh the screen. Changing the code could bean interesting first test of the library.Error handlingThere are two kinds of errors: local errors, generated bythe application (mostly because of connection problems),and remote errors, generated by the remote object. In bothcases the function being executed fails. The get* functionsreturn false when they fail; the set* and exec functionsreturn a null string; and in both cases you can use thegetLastError( ) method to retrieve the actual error number.Another approach would be to derive your own clientclass from ROB_Client and implement the iError( ) virtualmethod, which is called by ROB_Client every time anerror occurs. This is probably not the best way to handleerrors since Java has the capability to use exceptions—butI’m not very familiar with it yet; I’m sure that any Javaprogrammer can do better than that.Fixes to the Centura ROB class libraryTesting the Java client gave me a chance to fix some errorsin the first version of the ROB library. The first problemwas the Winsock version clash. I was requesting version2.0, which caused Centura’s TCP/IP router to fail if calledafter the ROB library had already allocated the Winsock.The reason is that the Winsock can be allocated multipletimes in the same process, but each subsequent allocationmust request the same version requested by the firstallocation. Centura’s routers request 1.1 and the ROBlibrary was requesting 2.0.The second problem was the way I handled blockingoperations. I was waiting in a loop, with yielding enabled,waiting for the entire packet to be received. This approachcause the server to go into a recursion if the messageswere too close to each other. Now I detect a blockingoperation right in the Winsock library, and I don’t get outof there until the whole packet is received or until atimeout error occurs. CPDownload the software discussed in this article from <strong>Pro</strong>Publishing’s Web site or obtain it from this month’sCompanion Disk.Figure 3. The Java applet-clientresult screen.Figure 4. The server transactions log.Gianluca Pivatodesigns LANs, WANs,databases, software,and anything thatinteracts with thesystem. Hegraduated in Italywith a degree indigital electronics,and he’s been in thecomputer businesssince 1982. Currently,he’s working on aproject for an Italianpatent andtrademark firm. Hiscompany is PivatoConsulting, inc. andhe can be reached atgianlucapivato@pipeline.com. He’salso selling Centuratools through hisnew online company,XSal,athttp://xsal.hexagon.net.http://www.<strong>Pro</strong>Publishing.comCentura <strong>Pro</strong> May 1998 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!