From eaa5203f84d9ad7571f0efbc8e05e34fa42da88f Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 11 Jan 2010 15:25:53 +0000 Subject: [PATCH] 2010-01-11 16:24 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + harbour/contrib/hbnetio/tests/netiot02.prg + added yet another example of NETIO client. It needs netiosrv executed on the same machine, see comments inside this code for details. --- harbour/ChangeLog | 6 ++ harbour/contrib/hbnetio/tests/netiot02.prg | 79 ++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 harbour/contrib/hbnetio/tests/netiot02.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index dbbeef902c..c4b48fb255 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-11 16:24 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + + harbour/contrib/hbnetio/tests/netiot02.prg + + added yet another example of NETIO client. + It needs netiosrv executed on the same machine, + see comments inside this code for details. + 2010-01-11 14:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbnetio/tests/netiotst.prg * added netio_disconnect() to test code diff --git a/harbour/contrib/hbnetio/tests/netiot02.prg b/harbour/contrib/hbnetio/tests/netiot02.prg new file mode 100644 index 0000000000..746aba359b --- /dev/null +++ b/harbour/contrib/hbnetio/tests/netiot02.prg @@ -0,0 +1,79 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * demonstration/test code for RPC in NETIO + * + * Copyright 2010 Przemyslaw Czerpak + * www - http://www.harbour-project.org + * + */ + + +/* to execute this code run server (netiosrv) on the same machine + * with support for RPC and "topsecret" password, i.e.: + * netiosrv "" "" "" 1 topsecret + * then you can try to execute this code. + * If you want to execute remotely any core functions then + * uncomment this like in netiosrv.prg: + * REQUEST __HB_EXTERN__ + * and rebuild it or link netiosrv with Harbour dynamic library + * (-shared hbmk2 switch) + */ + + +/* few PP rules which allow to execute RPC function using + * pseudo object 'net', i.e. ? net:date() + */ +#xtranslate net:([]) => ; + netio_funcexec( # [,] ) +#xtranslate net:[]:([]) => ; + netio_funcexec( [ # + ] ":" + # [,] ) +#xtranslate net:[]::([]) => ; + netio_funcexec( [ # + ] ":" + # + ":" + # ; + [,] ) + +#xtranslate net:exists: => ; + netio_procexists( # ) +#xtranslate net:exists:[]: => ; + netio_procexists( [ # + ] ":" + # ) +#xtranslate net:exists:[]:: => ; + netio_procexists( [ # + ] ":" + # + ":" + # ) + + +/* address of computer executing netiosrv, + * change it if it's not the same machine + */ +#define NETSERVER "127.0.0.1" +#define NETPORT 2941 +#define NETPASSWD "topsecret" + + +proc main() + + /* connect to the server */ + ? "CONNECTING..." + ? "NETIO_CONNECT():", netio_connect( NETSERVER, NETPORT,, NETPASSWD ) + ? + /* check if some function are available on server side */ + ? "DATE() function is supported:", net:exists:DATE + ? "QOUT() function is supported:", net:exists:QOUT + ? "HB_DATETIME() function is supported:", net:exists:HB_DATETIME + ? + /* display text on server console */ + net:QOUT( repl( "=", 70 ) ) + net:QOUT( "This is RPC TEST", hb_datetime(), version() ) + net:QOUT( repl( "=", 70 ) ) + + /* execute some functions on the server side and display the results */ + ? "SERVER DATE:", net:DATE() + ? "SERVER TIME:", net:TIME() + ? "SERVER DATETIME:", net:HB_DATETIME() + ? net:upper( "hello world !!!" ) + ? + + /* close the connection to the server */ + ? "NETIO_DISCONNECT():", netio_disconnect( NETSERVER, NETPORT ) +return