Netio Client Server

Selama ini database DBF sangat rentan dalam hal security dan tidak bisa diproses dengan model client server kecuali pakai software tambahan yg kmomersil seperti ADS ( Advantage Database Server ) .
Saat ini ada NETIO SERVER dan diharapkan mampu untuk menutupi kelemahan dari DATABASE DBF ,

This is screen shoot and coding Netio client server ;

This is coding client server with Netio

* PROGRAMM : Simple NET I/O Server (+ Client conn.), based upon excellent
* NETIO lib for Harbour, by Przemyslaw Czerpak.
* Author: Pete D. – March 2010
* LICENCE: Free (GPL) for any use (like in ‘free speach’, but always at your own risk!)
*/

#include
#include
#define CRLF HB_OSNewLine()

// #define NET_ADDRESS “127.0.0.1”
#define NET_ADDRESS Main.Text_IP.Value
#define NET_PORT Main.Text_Port.Value
#define NET_PASSWD ALLTRIM( IIF(Main.Check_ENC.Value, Main.Text_Pass.Value, “”) )
#define NET_DIR Main.Text_DIR.Value
#define NET_RPC Main.Check_RPC.Value
#define NET_ENC Main.Check_ENC.Value
#define NET_PATH “net:” + NET_ADDRESS + “:” + HB_NToS( NET_PORT ) + ;
IF( !Empty( NET_PASSWD ), “:” + NET_PASSWD, “”) + “:”

// REQUEST __HB_EXTERN__

REQUEST DBFCDX

STATIC pListenSocket := NIL
STATIC lIsConnection := .F.
STATIC lClientMode := .F.

Function Main()

set exclusive off
rddSetDefault( “DBFCDX” )

// lClientMode := msgYesNo( “Start in Client mode?”, “CLIENT/SERVER” )

Load Window Main

IF lClientMode
Main.Button_StartServer.Enabled := .F.
Main.Button_StopServer.Enabled := .F.
Main.M_STARTS.Enabled := .F.
Main.M_STOPS.Enabled := .F.
Main.Tab_1.Value := 2
ENDIF

Main.Center

Main.Activate

Return

PROCEDURE NotifyIconClick()
Local hWnd := GetFormHandle(‘Main’ )
IF IsWIndowDefined(Main)
If IsWindowVisible( hWnd )
Main.Hide
Else
Main.Show
IF IsIconic( hWnd )
Main.Restore
ENDIF
EndIf
ENDIF

**********************
Function StartServer()
LOCAL cPassword := NET_PASSWD
DECLARE WINDOW Main

pListenSocket := netio_mtserver( NET_PORT, NET_ADDRESS, ;
NET_DIR, NET_RPC, ;
@cPassword )
IF ! Empty(pListenSocket)
Main.Image_ServerStatus.Hide
// Main.Image_ServerStatus.Picture := “NetFolder.jpg”
Main.Image_ServerStatus.Picture := “NETFLD_PIC”
Main.Image_ServerStatus.Refresh
Main.Image_ServerStatus.Show
MsgInfo( “Good news! server started and is listening at Port: “+HB_NToS(NET_PORT), “START SERVER” )
ELSE

MsgExclamation(“Sadly enough, I was unable to start server!”+CRLF+;
“(Check Port and/or IPAddress)”,”START SERVER” )
Main.Image_ServerStatus.Picture := “NETFLD_PIC”
ENDIF

Return Nil

*********************
Function StopServer()

IF ! Empty(pListenSocket)
Main.Image_ServerStatus.Hide
netio_serverstop( pListenSocket, .T. )
pListenSocket := NIL

Main.Image_ServerStatus.Picture := “”
Main.Image_ServerStatus.Refresh
Main.Image_ServerStatus.Show

MsgInfo(“Server stopped!”, “STOP SERVER”)
ELSE
MsgExclamation(“Hey! cannot stop a non-started Server!”, “STOP SERVER”)
ENDIF
Return Nil

*********************
PROCEDURE ServerSpecs
LOCAL cSpecs
IF ! Empty(pListenSocket)
cSpecs := CRLF + ;
” NETIO_SERVER IP : ” + NET_ADDRESS + CRLF + ;
” LISTENING PORT : ” + hb_ntos( NET_PORT ) + CRLF + ;
” RPC ACTIVE : ” + IF(NET_RPC, “Yes”, “No”) + CRLF + ;
” ENCRYPTION : ” + IF(NET_ENC, “Yes”, “No”) + CRLF + ;
” PASSWORD : ” + NET_PASSWD + CRLF + ;
” NET FULLPATH : ” + NET_PATH + CRLF
BrowseText( cSpecs, “SERVER SPECS” )
ELSE
MsgExclamation(“No Server seems to been started, on this machine!”, “Stop Server”)
ENDIF
RETURN

******************
Function QuitApp()
DECLARE WINDOW Main
IF ! Empty(pListenSocket)
StopServer()
ENDIF
Main.release
Return Nil

****************
Function About()
MsgInfo(“Simple NET I/O Server (+ Client conn.), based upon excellent”+CRLF+;
“NETIO lib for Harbour, by Przemyslaw Czerpak” + CRLF + ;
“Author Pete D. – March 2010” + CRLF + ;
“Free for any use (like in ‘free speach’, but always at your own risk😉 )”,;
“Simple NET I/O Server”)
Return Nil

*********************
Function ManagePass()
DECLARE WINDOW Main
IF NET_ENC
Main.Text_Pass.Enabled := .T.
ELSE
Main.Text_Pass.Value := “”
Main.Text_Pass.Enabled := .F.
ENDIF
RETURN Nil

#include “Directry.ch”

**********************************
Function ClientConnect( lConnect )
LOCAL aDirectory := {}
LOCAL aGrid := {}
DEFAULT lConnect TO (Main.Button_Connect.Caption == “Connect to Server”)
IF lConnect
lIsConnection := NetIO_Connect( NET_ADDRESS, NET_PORT, , NET_PASSWD )
IF ( lIsConnection )

Main.Image_ConnectionStatus.Hide
Main.Image_ConnectionStatus.Picture := “CONECT_PIC”
Main.Image_ConnectionStatus.Show
MsgInfo( “Connection established!”, “CONNECT” )

IF NET_RPC
Main.Grid_DBF.DeleteAllItems()
aDirectory := netio_funcexec( “Directory”, “*.dbf” )
FOR nI := 1 to len(aDirectory)
Main.Grid_DBF.AddItem(MakeItem(aDirectory[nI]))
NEXT
ENDIF
Main.Button_Connect.Caption := “Disconnect..”
ELSE
MsgExclamation( “Bad news! Could not connect…”, “CONNECT” )
ENDIF
ELSE
IF lIsConnection
lConnect := netio_disconnect( NET_ADDRESS, NET_PORT )
IF lConnect
Main.Image_ConnectionStatus.Hide
Main.Image_ConnectionStatus.Picture := “”
Main.Image_ConnectionStatus.Refresh
Main.Image_ConnectionStatus.Show
MsgInfo( “Disconected from Server!”, “DISCONNECT” )

lIsConnection := ! lConnect
Main.Grid_DBF.DeleteAllItems()
Main.Button_Connect.Caption := “Connect to Server”
ELSE
MsgExclamation( “Strange, but could not disconnect!”, “DISCONNECT” )
ENDIF
ENDIF
ENDIF

Return Nil

************************
STATIC FUNCTION MakeItem( aEle )
RETURN { PadR( aEle[ F_NAME ], 15 ) , hb_ntos( aEle[ F_SIZE ] ),;
DToC( aEle[ F_DATE ] ), aEle[ F_TIME ] }

************************
FUNCTION BrowseThisDBF()
LOCAL cDBF := Main.Grid_DBF.Item(Main.Grid_DBF.Value)[1]
IF !Empty(cDbf)
cDBF := NET_PATH + Main.Grid_DBF.Item(Main.Grid_DBF.Value)[1]
USE (cDBF)
EDIT EXTENDED
ELSE
msgStop(“No file Selected for browse!”, “BROWSE DBF”)
ENDIF
RETURN Nil

****************
Function Usage()
BrowseText(‘Readme.rtf’, ‘NETIO LIB DOCUMENTATION’, .T.)
Return Nil

******************
FUNCTION ExecPROC()
LOCAL cParams
LOCAL lResult := .F.
LOCAL Title := “Execute PROCEDURE”
LOCAL aL := {“PROCNAME”, “PROCPARAM_1”, “PROCPARAM_2”}
LOCAL aIV := {“”, “”, “”}
LOCAL aF := {20, 20, 20}
LOCAL aProc

aProc := InputWindow( Title, aL, aIV, aF )
IF ISNIL( aProc[1] )
RETURN lResult
ENDIF
cParams := alltrim(aProc[2])+ if( empty(aProc[3]),””, “,”+alltrim(aProc[3] ) )

// cParams := if(empty(cParams, “”, “,”+cParams))

IF ( lResult := NETIO_PROCEXECW( aProc[1], cParams ) )
msgInfo( “Given PROC ” + aProc[1] + ” executed on server side” )
ELSE
msgInfo( “Given PROC ” + aProc[1] + ” not executed on server side” )
ENDIF

RETURN lResult

#pragma BEGINDUMP
#define HB_OS_WIN_USED
#define _WIN32_WINNT 0x0400
#include
#include “hbapi.h”
#include “hbapiitm.h”
HB_FUNC( ISICONIC )
{
hb_retl( IsIconic( ( HWND ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMP

#include ‘funcs.prg’

// Getlasterror() in minigui.lib must be commented out and rebuild. It is included in HBWIn lib of later Harbour releases.

/*

NETIO_LISTEN( [], [], [], [] ) -> | NIL

NETIO_ACCEPT( , [],
[], [], [] )
-> | NIL

NETIO_COMPRESS( ,
[], [], [] ) -> NIL

NETIO_SERVER( ) -> NIL

NETIO_RPC( | [, ] ) ->

NETIO_RPCFILTER( , | | NIL ) -> NIL

NETIO_SERVERSTOP( | [, ] ) -> NIL

NETIO_MTSERVER( [], [], [],
[ | | ],
[], [], [] )
->

*/

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: