Re: [Harbour] HBNetIO file functions
Mindaugas Kavaliauskas wrote: Here is a sample code, how I copy data.dbf to MEMIO for a much faster report generation using memory file instead of (possibly remote) file. If you change data.dbf to net:data.dbf you'll have a function to NETIO file to MEMIO file. I briefly looked to see if I thought I could write something for myself. Your code demonstrates interesting possibilities. If your next question is about, why IO API is not directly accessible via Harbour level functions, the answer is: because IO API functionality is not as wide as all Harbour level functions. So, many Harbour functions could not be redirected via IO API. IO API can't be far from that goal if all file operations required to handle an RDD are implemented. I guess tell, seek, locking, directory manipulation and status (eof) at least are missing. Thank you for the information. Regards Alex ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
[Harbour] HBNetIO file functions
Hi Maybe this small test will help someone to see how easy it is to read and write non DBF files using netio RPC. Regards Alex /* * $Id: netiot04.prg 14415 2010-04-30 09:39:25Z druzus $ */ /* * Harbour Project source code: *demonstration/test code for alternative RDD IO API, RPC and *asynchronous data streams in NETIO * * Copyright 2010 Przemyslaw Czerpak druzus / at / priv.onet.pl * www - http://www.harbour-project.org * */ /* net:127.0.0.1:2941:topsecret:data/_tst_ */ #include fileio.ch #define DBSERVER 127.0.0.1 #define DBPORT2941 request FILE request FCREATE request FOPEN request FSEEK request FWRITE request NETFREAD request FCLOSE proc main() local pSockSrv local cFile := hello.txt local nHandle local cData := Hello HBNetIO local lExists local cBuffer pSockSrv := netio_mtserver( DBPORT,,, /* RPC */ .T. ) if empty( pSockSrv ) ? Cannot start NETIO server !!! wait Press any key to exit... quit endif ? NETIO server activated. hb_idleSleep( 0.1 ) ? ? NETIO_CONNECT():, netio_connect( DBSERVER, DBPORT ) ? ? FILE:, lExists := netio_funcexec( file, cFile ) if lExists ? FOPEN:, nHandle := netio_funcexec( fopen, cFile, FO_WRITE ) ? FSEEK:, netio_funcexec( fseek, nHandle, 0, FS_END ) else ? FCREATE:, nHandle := netio_funcexec( fcreate, cFile ) endif ? FWRITE:, netio_funcexec( fwrite, nHandle, time() ) ? FWRITE:, netio_funcexec( fwrite, nHandle, + cData ) cData := chr(13) + chr(10) ? FWRITE:, netio_funcexec( fwrite, nHandle, cData ) ? FCLOSE:, netio_funcexec( fclose, nHandle ) ? ? FOPEN:, nHandle := netio_funcexec( fopen, cFile, FO_READ ) while !empty( cBuffer := netio_funcexec( netfread, nHandle ) ) ? cBuffer end ? FCLOSE:, netio_funcexec( fclose, nHandle ) ? ? stopping the server... netio_serverstop( pSockSrv, .t. ) return function netfread( nHandle ) local cBuffer := space( 1024 ) local nRead if ( nRead := fread( nHandle, @cBuffer, 1024 ) ) = 0 return NIL endif return left( cBuffer, nRead ) ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] HBNetIO file functions
Hello, I suggest to add this example to the contrib\hbnetio\tests folder. With more examples it is better to understand. I will try NETIO in the future, seems something very good and professional. I am afraid I don't know the power and possibilities of it yet. Thanks! Qatan - Original Message - From: Alex Strickland s...@mweb.co.za To: Harbour Project Main Developer List. harbour@harbour-project.org Sent: Tuesday, 4 de May de 2010 11:30 Subject: [Harbour] HBNetIO file functions Hi Maybe this small test will help someone to see how easy it is to read and write non DBF files using netio RPC. Regards Alex ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] HBNetIO file functions
+1 2010/5/4 Qatan supo...@tribalbrasil.com Hello, I suggest to add this example to the contrib\hbnetio\tests folder. With more examples it is better to understand. I will try NETIO in the future, seems something very good and professional. I am afraid I don't know the power and possibilities of it yet. Thanks! Qatan -- Massimo Belgrano ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] HBNetIO file functions
Hi, On 2010.05.04 17:30, Alex Strickland wrote: Maybe this small test will help someone to see how easy it is to read and write non DBF files using netio RPC. The primary purpose of NETIO was file sharing, so, it supports this functionality even without RPC and without any Harbour level overhead. Here is a sample code, how I copy data.dbf to MEMIO for a much faster report generation using memory file instead of (possibly remote) file. If you change data.dbf to net:data.dbf you'll have a function to NETIO file to MEMIO file. pFile = hb_fileExtOpen( data.dbf, NULL, FO_READ | FO_DENYNONE | FXO_DEFAULTS, NULL, NULL ); if( pFile ) { if( hb_fileLock( pFile, 0, ( HB_FOFFSET ) -1, FL_LOCK | FLX_EXCLUSIVE ) ) { pFileTo = hb_fileExtOpen( mem:data.dbf, NULL, FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS, NULL, NULL ); if( pFileTo ) { ulPos = 0; pBuffer = hb_xgrab( 1048576 ); while( ( ulCount = hb_fileReadAt( pFile, pBuffer, 1048576, ulPos ) ) 0 ) { hb_fileWriteAt( pFileTo, pBuffer, ulCount, ulPos ); if( ulCount != 1048576 ) break; ulPos += 1048576; } hb_fileClose( pFileTo ); } hb_fileLock( pFile, 0, ( HB_FOFFSET ) -1, FL_UNLOCK ); } hb_fileClose( pFile ); } If your next question is about, why IO API is not directly accessible via Harbour level functions, the answer is: because IO API functionality is not as wide as all Harbour level functions. So, many Harbour functions could not be redirected via IO API. Regards, Mindaugas ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] HBNetIO file functions
Hi Qatan, On 5/5/2010 12:52 AM, harbour-requ...@harbour-project.org wrote: Message: 1 Date: Tue, 4 May 2010 13:09:52 -0300 From: Qatansupo...@tribalbrasil.com Subject: Re: [Harbour] HBNetIO file functions To: Harbour Project Main Developer List. harbour@harbour-project.org Message-ID:6ee9632a6a5a48ebb01c525d65f24...@supports Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Hello, I suggest to add this example to the contrib\hbnetio\tests folder. With more examples it is better to understand. I will try NETIO in the future, seems something very good and professional. I am afraid I don't know the power and possibilities of it yet. Well, in my experience after conversion, the speed difference is very noticeable on a heavy traffic network compared to a shared access application. I can also set the shared folder to Read Only from the server for direct file access security (accidental deletion?) while performing the normal application process via NETIO. I just need a variable that contains like cFileSvr:=net:serverhost:server dbf folder then open dbf file as DbUseArea(.T., ,(cFileSvr+dbfile)). I can then simply set cFileSvr:= to operate on Non-NETIO environment. Personally, it is that flexible to switch between the usual way of opening dbf files and NETIO to achieve its amazing benefit. Thanks! Qatan Mario ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour
Re: [Harbour] HBNetIO file functions
Hello Mario, Well, in my experience after conversion, the speed difference is very noticeable on a heavy traffic network compared to a shared access application. I can also set the shared folder to Read Only from the server for direct file access security (accidental deletion?) while performing the normal application process via NETIO. I just need a variable that contains like cFileSvr:=net:serverhost:server dbf folder then open dbf file as DbUseArea(.T., ,(cFileSvr+dbfile)). I can then simply set cFileSvr:= to operate on Non-NETIO environment. Personally, it is that flexible to switch between the usual way of opening dbf files and NETIO to achieve its amazing benefit. Thanks for sharing your experience. It helps Seems pretty simple. I will try when I have time and more resources (2 computers). Regards, Qatan ___ Harbour mailing list (attachment size limit: 40KB) Harbour@harbour-project.org http://lists.harbour-project.org/mailman/listinfo/harbour