Code: Select all
Revision: 12382
http://harbour-project.svn.sourceforge.net/harbour-project/?rev=12382&view=rev
Author: druzus
Date: 2009-08-31 22:56:45 +0000 (Mon, 31 Aug 2009)
Log Message:
-----------
2009-09-01 00:56 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/harbour.spec
* harbour/harbour-win-spec
* harbour/harbour-wce-spec
* harbour/bin/hb-func.sh
* harbour/contrib/Makefile
+ harbour/contrib/hbnetio
+ harbour/contrib/hbnetio/netio.h
+ harbour/contrib/hbnetio/netiomt.prg
+ harbour/contrib/hbnetio/netiocli.c
+ harbour/contrib/hbnetio/netiosrv.c
+ harbour/contrib/hbnetio/Makefile
+ added new library: HBNETIO.
It implements alternative RDD IO API which uses own TCP/IP sockets
to exchange data between client and server.
This library contains client and server code and is fully MT safe.
On client side it's enough to execute:
NETIO_CONNECT( [<cServer>], [<cPort>], [<nTimeOut>] ) -> <lOK>
function to register alternative NETIO RDD API and set default
server address and port.
<cServer> - server addres (default 127.0.0.1)
<cPort> - server port (default 2941)
<nTimeOut> - connection timeout (default -1 - not timeout)
Above settings are thread local and parameters of the 1-st successful
connection are used as default values for each new thread.
After registering NETIO client by above function each file starting
"net:" prefix is automatically redirected to given NETIO server, i.e.
use "net:mytable"
It's also possible to pass NETIO server and port as part of file name,
i.e.:
use "net:192.168.0.1:10005:mytable"
On the server side the following functions are available:
create NETIO listen socket:
NETIO_LISTEN( [<nPort>], [<cAddress>], [<cRootDir>] )
-> <pListenSocket> | NIL
accept new connection on NETIO listen socket:
NETIO_ACCEPT( <pListenSocket> [, <nTimeOut>] )
-> <pConnectionSocket> | NIL
start connection server:
NETIO_SERVER( <pConnectionSocket> ) -> NIL
stop connection accepting or connection server:
NETIO_SERVERSTOP( <pListenSocket> | <pConnectionSocket>, <lStop> )
-> NIL
activate MT NETIO server (it needs MT HVM):
NETIO_MTSERVER( [<nPort>], [<cAddress>] ) -> <pListenSocket> | NIL
To create NETIO server is enough to compile and link with MT HVM
this code:
proc main()
local pListenSocket
pListenSocket := netio_mtserver()
if empty( pListenSocket )
? "Cannot start server."
else
wait "Press any key to stop NETIO server."
netio_serverstop( pListenSocket )
pListenSocket := NIL
endif
return
NETIO works with all core RDDs (DBF, DBFFPT, DBFBLOB, DBFNTX, DBFCDX,
DBFNSX, SDF, DELIM) and any other RDD which inherits from above or
use standard RDD IO API (hb_file*() functions).
Without touching even single line in RDD code it gives the same
functionality as REDBFCDX in xHarbour but for all RDDs.
It's possible that such direct TCP/IP connection is faster then
file server protocols especially if they need more then one IP frame
to exchange data so it's one of the reason to use it in such cases.
Please make real speed tests.
The second reason to use NETIO server is resolving problem with
concurrent access to the same files using Harbour applications
compiled for different platforms, i.e. DOS, LINUX, Windows and OS2.
It's very hard to configure all client stations to use correct
locking system. NETIO fully resolves this problem so it can be
interesting alternative also for MS-Windows users only if they
do not want to play with oplocks setting on each station.
I'm interesting in user opinions about real life NETIO usage.
Have a fun with this new toy ;-)
+ harbour/contrib/hbnetio/tests
+ harbour/contrib/hbnetio/tests/netiotst.prg
+ harbour/contrib/hbnetio/tests/netiotst.hbp
+ harbour/contrib/hbnetio/tests/data
+ added simple test code for NETIO. It activates NETIO MT server
and then connects to this server to create and browse table with
memo file and production index with few tags.
Modified Paths:
--------------
trunk/harbour/ChangeLog
trunk/harbour/bin/hb-func.sh
trunk/harbour/contrib/Makefile
trunk/harbour/harbour-wce-spec
trunk/harbour/harbour-win-spec
trunk/harbour/harbour.spec
Added Paths:
-----------
trunk/harbour/contrib/hbnetio/
trunk/harbour/contrib/hbnetio/Makefile
trunk/harbour/contrib/hbnetio/netio.h
trunk/harbour/contrib/hbnetio/netiocli.c
trunk/harbour/contrib/hbnetio/netiomt.prg
trunk/harbour/contrib/hbnetio/netiosrv.c
trunk/harbour/contrib/hbnetio/tests/
trunk/harbour/contrib/hbnetio/tests/data/
trunk/harbour/contrib/hbnetio/tests/netiotst.hbp
trunk/harbour/contrib/hbnetio/tests/netiotst.prg
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour
Roberto.