Senhores,
alguém já conseguiu usar um servidor de dns tipo no-ip ou dyndns com o netio?
[]´s
Moderador: Moderadores
IF!Netio_FuncExec("EXISTEINDICE","BOLETOS.CDX")
CriaIndice("BOLETOS.CDX")
ENDIF
IF!Netio_FuncExec("EXISTEINDICE","BOLETOS.CDX")
CriaIndice("BOLETOS.CDX")
ENDIF
IF !Netio_FuncExec("LOCALIZAINDICE","PONTO.CDX")
NetUse(cServer,cDataBase,.T.)
INDEX ON DTOS(DATA) TAG I001 TO (cServer+"PONTO")
INDEX ON DTOS(DATA) TAG I002 DESCEND TO (cServer+"PONTO")
PONTO->(DBCLOSEAREA())
ENDIF
#include "hwgui.ch"
#include "common.ch"
#include "windows.ch"
#include "guilib.ch"
FUNCTION Main( nPort, cIfAddr, cRootDir, xRPC, ... )
LOCAL hWrite := Hash(), hRead:= HB_ReadIni( "CONFIG.INI" )
LOCAL oTrayMenu
LOCAL oIconIni:=HIcon():AddResource("ICON_2")
PRIVATE pListenSocket, c_Port:="2816", c_Path:="\DB", c_Addr:=Verifica_Ip()
REQUEST HB_DATETIME
MEMVAR->oIcon1 :=HIcon():AddResource("ICON_1")
MEMVAR->oIcon2 :=HIcon():AddResource("ICON_2")
MEMVAR->oMainWindow:=Nil
MEMVAR->oTimer :=Nil
IF !FILE("CONFIG.INI")
hWrite["MAIN" ] := Hash()
hWrite["MAIN" ]["Desc" ] := "Sistema Servidor - NetIO"
hWrite["MAIN" ]["Ver" ] := "Versao 1.2"
hWrite["CONFIGURACAO" ] := Hash()
hWrite["CONFIGURACAO" ]["Port"] := c_Port
hWrite["CONFIGURACAO" ]["Path"] := c_Path
hWrite["CONFIGURACAO" ]["Addres"] := c_Addr
HB_WriteIni( "CONFIG.INI", hWrite,"--- Inicio ---", "--- Fim ---" )
ELSE
c_Port:=hRead["CONFIGURACAO"]["Port"]
c_Path:=hRead["CONFIGURACAO"]["Path"]
c_Addr:=hRead["CONFIGURACAO"]["Addres"]
ENDIF
cServidorDB:='//'+c_Addr+':'+c_Port+'/'
INIT WINDOW MEMVAR->oMainWindow MAIN TITLE "Servidor NetIO - "+cServidorDB
pListenSocket := NetIO_mtServer( VAL(c_Port),c_Addr,,.T.)
IF Empty(pListenSocket)
MsgInfo( "Servidor não pode ser inicializado em "+c_Addr+":"+c_Port)
EndWindow()
ENDIF
CONTEXT MENU oTrayMenu
MENUITEM "Parar o Servidor" ACTION PararServidor()
MENUITEM "Reiniciar o Servidor" ACTION IniciarServidor()
SEPARATOR
MENUITEM "Sair" ACTION Sair()
ENDMENU
Liga_Timer(MEMVAR->oMainWindow,.T.)
MEMVAR->oMainWindow:InitTray( oIconIni,,oTrayMenu,"Servidor NetIO - "+cServidorDB )
ACTIVATE WINDOW oMainWindow NOSHOW
oTrayMenu:End()
RETURN Nil
FUNCTION MudaIcone
STATIC nIcon
MEMVAR oMainWindow
MEMVAR oIcon1
MEMVAR oIcon2
IF nIcon = Nil
nIcon:=1
ENDIF
Liga_Timer(oMainWindow,.F.)
nIcon := IF(nIcon > 2, 1, nIcon)
Muda_Icone(IF(nIcon=1,oIcon1,oIcon2))
nIcon++
Liga_Timer(oMainWindow,.T.)
RETURN Nil
FUNCTION Muda_Icone(oIconeX, cTexto)
LOCAL oIcon := oIconeX
MEMVAR oMainWindow
ShellModifyIcon( oMainWindow:handle, oIcon:handle)
oMainWindow:Refresh()
RETURN Nil
FUNCTION Liga_Timer(oJanela,lLiga)
MEMVAR oTimer
IF lLiga
SET TIMER oTimer of oJanela VALUE 1000 ACTION {|| MudaIcone() }
ELSE
oJanela:oTimer:End()
ENDIF
RETURN Nil
FUNCTION Sair
MEMVAR oMainWindow
Liga_Timer(oMainWindow,.F.)
oMainWindow:oTimer:End()
IF MsgNoYes("Deseja Realmente Sair do Programa ?","Aviso do Sistema")
PararServidor()
Liberar()
ELSE
Liga_Timer(oMainWindow,.T.)
RETURN Nil
ENDIF
RETURN Nil
FUNCTION Liberar
EndWindow()
ExitProcess()
RETURN Nil
FUNCTION PararServidor
MEMVAR pListenSocket
IF !Empty( pListenSocket )
NetIO_ServerStop( pListenSocket )
pListenSocket := NIL
//MsgInfo( "Servidor foi parado em "+c_Addr+":"+c_Port)
ENDIF
RETURN Nil
FUNCTION IniciarServidor
MEMVAR pListenSocket
IF Empty(pListenSocket)
PararServidor()
pListenSocket := NetIO_mtServer( VAL(c_Port),c_Addr,,.T.)
IF Empty(pListenSocket)
MsgInfo( "Servidor não pode ser inicializado em "+c_Addr+":"+c_Port)
EndWindow()
ELSE
MsgInfo( "Servidor foi inicializado em "+c_Addr+":"+c_Port)
ENDIF
ENDIF
RETURN Nil
FUNCTION Verifica_Ip
LOCAL aHosts, cName, cEstacao:=netname(.f.)
hb_InetInit()
aHosts := hb_InetGetHosts( cEstacao )
IF aHosts == NIL
aHosts := hb_InetGetAlias( cEstacao )
ENDIF
IF Empty(aHosts)
aHosts := hb_InetGetAlias( cEstacao )
ENDIF
hb_InetCleanup()
RETURN ahosts[1]
FUNCTION LOCALIZAINDICE(cIndice)
LOCAL lOk:=.F.
IF FILE("DB\"+cIndice)
lOk:=.T.
ENDIF
RETURN lOk
#pragma BEGINDUMP
#define _WIN32_IE 0x0500
#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400
#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
#include "hbapiitm.h"
HB_FUNC( SHOWERROR )
{
LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox(NULL, (LPCSTR)lpMsgBuf, "Shutdown", MB_OK | MB_ICONEXCLAMATION);
// Free the buffer.
LocalFree( lpMsgBuf );
}
HB_FUNC( ENABLEPERMISSIONS )
{
LUID tmpLuid;
TOKEN_PRIVILEGES tkp, tkpNewButIgnored;
DWORD lBufferNeeded;
HANDLE hdlTokenHandle;
HANDLE hdlProcessHandle = GetCurrentProcess();
OpenProcessToken(hdlProcessHandle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hdlTokenHandle);
LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &tmpLuid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = tmpLuid;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hdlTokenHandle, FALSE, &tkp, sizeof(tkpNewButIgnored), &tkpNewButIgnored, &lBufferNeeded);
}
HB_FUNC( EXITWINDOWSEX )
{
hb_retl( ExitWindowsEx( (UINT) hb_parni( 1 ), (DWORD) hb_parnl( 2 ) ) );
}
HB_FUNC( LOADTRAYICON )
{
HICON himage;
HINSTANCE hInstance = (HINSTANCE) hb_parnl(1); // handle to application instance
LPCTSTR lpIconName = (LPCTSTR) hb_parc(2); // name string or resource identifier
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 16, 16, LR_SHARED ) ;
if (himage==NULL)
{
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) ;
}
hb_retnl ( (LONG) himage );
}
HB_FUNC( LOADMAINICON )
{
HICON himage;
HINSTANCE hInstance = (HINSTANCE) hb_parnl(1); // handle to application instance
LPCTSTR lpIconName = (LPCTSTR) hb_parc(2); // name string or resource identifier
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_DEFAULTSIZE ) ;
if (himage==NULL)
{
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) ;
}
hb_retnl ( (LONG) himage );
}
static HWND GetStartButton(void);
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle);
HB_FUNC ( SHOWNOTIFYINFO )
{
ShowNotifyInfo( (HWND) hb_parnl(1), (BOOL) hb_parl(2), (HICON) hb_parnl(3), (LPSTR) hb_parc(4),
(LPSTR) hb_parc(5), (LPSTR) hb_parc(6) );
}
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle)
{
NOTIFYICONDATA nid;
ZeroMemory( &nid, sizeof(nid) );
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hIcon = hIcon;
nid.hWnd = hWnd;
nid.uID = 0;
nid.uFlags = NIF_INFO | NIF_TIP | NIF_ICON;
nid.dwInfoFlags = NIIF_INFO;
lstrcpy( nid.szTip, TEXT(szText) );
lstrcpy( nid.szInfo, TEXT(szInfo) );
lstrcpy( nid.szInfoTitle, TEXT(szInfoTitle) );
if(bAdd)
Shell_NotifyIcon( NIM_ADD, &nid );
else
Shell_NotifyIcon( NIM_DELETE, &nid );
if(hIcon)
DestroyIcon( hIcon );
}
HB_FUNC ( SETSTARTBUTTONIMAGE )
{
HWND hButton = GetStartButton();
HDC hDCButton = GetDC(hButton);
HDC hDcCompatibleButton;
RECT rc;
int nWidth, nHeight;
HBITMAP hBitmap, hBitmapOld;
BITMAP bitmap;
GetWindowRect(hButton, &rc);
nWidth = rc.right - rc.left;
nHeight = rc.bottom - rc.top;
hDcCompatibleButton = CreateCompatibleDC(hDCButton);
hBitmap = (HBITMAP)LoadImage (NULL, hb_parc(1), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
hBitmapOld = (HBITMAP)SelectObject(hDcCompatibleButton, hBitmap);
GetObject(hBitmap, sizeof(BITMAP), &bitmap);
if (nWidth > bitmap.bmWidth - 3 && nWidth < bitmap.bmWidth + 3 && nHeight > bitmap.bmHeight - 3 && nHeight < bitmap.bmHeight + 3)
BitBlt(hDCButton, 0, 0, nWidth, nHeight, hDcCompatibleButton, 0, 0, SRCCOPY);
else
StretchBlt(hDCButton, 0, 0, nWidth, nHeight, hDcCompatibleButton, 0, 0, bitmap.bmWidth, bitmap.bmHeight, SRCCOPY);
SelectObject(hDcCompatibleButton, hBitmapOld);
DeleteDC(hDcCompatibleButton);
DeleteDC(hDCButton);
DeleteObject(hBitmap);
}
static HWND GetStartButton()
{
static HWND hKnownButton=0;
HWND hTaskBar, hButton;
hTaskBar = FindWindow( "Shell_TrayWnd", NULL );
hButton = GetWindow( hTaskBar, GW_CHILD );
if (hButton)
hKnownButton = hButton;
else
hButton = hKnownButton;
return hButton;
}
HB_FUNC( GETKEYBOARDMODE )
{
HKL kbl;
HWND CurApp;
DWORD idthd;
int newmode;
CurApp=GetForegroundWindow();
idthd=GetWindowThreadProcessId(CurApp,NULL);
kbl=GetKeyboardLayout(idthd);
newmode=(int)LOWORD(kbl);
hb_retnl(newmode);
}
#pragma ENDDUMP
ASimoes escreveu:
"Resumindo, no letodb posso usar todas as funções que ele oferece usando ip local ou dns host,
no NetIO, somente com ip local, me corrijam se eu estiver errado, pelo menos fiquei tentando descobrir por horas e nada. Falta mais documentação sobre o uso desta lib."
Eu deixei o letodb de lado por conta daquele problema do indice, não sei se já foi resolvido,
'Under the hood' works now a *TWO-socket* TCP connection ( if client application is MultiThread compiled ),
enabling e,g, much faster data writes to the server.
Available is on demand an extreme fast LZ4 compress- and Blowfish-encrypt-able network traffic.
LetoDBf client lib ( used by your application ) became fully MultiThread save, each thread opens its own
connection to the server. Threads, threads threads .., wherever you look.
+ compression for LetoFileWrite() and LetoMemoWrite()
% increase max receive block size: 0x7FFFFFFF aka 2GB - 32MB
; may test such big blocks handles
4.2.4 Compression LZ4 / ZLib
Default is to use highspeed realtime LZ4 compression algorithm, but stoneage BCC 5.5 compiler cannot use it !
This can be changed to classic ( slower! ) ZLib compression by outcommenting with set a < # > into first position
of the corresponding .hbp files, found at very top the line with: "#-env:__LZ4=yes"
I would very recommend lightning fast LZ4.
Re-compile both!! server executable and client library. This must fit together, a server with LZ4 won't understand
a client application with ZLib.
Additional remark: at least stoneage old BCC 5.5 had problems with using LZ4, so it is outcommented for all BCC
versions. If you want to try it with a newer BCC version you have to remove that: "{!bcc}" in the HBP files.
Leto_FCopyToSrv( cLocalFileName, sServerFileName[, nStepSize ] )
==> lSuccess
Leto_FCopyFromSrv( cLocalFileName, sServerFileName[, nStepSize ] )
==> lSuccess
Copy a file from/ to client to/ from server, where:
<cLocalFileName> is filename at client side,
<sServerFileName> is filename at server which can contain connection info "//IP:port/".
Optional <nStepSize> determine the size of bytes to be copied with one step, default if
not given is 1 MB.
<sServerFileName> can only contain prefix: "mem:" for files in RAM,
<cLocalFileName> can contain any redirector prefix known by Harbour.
A simple backup:
aArr := Leto_Directory( "*" )
AEval( aArr, { |aItem| Leto_FCopyFromSrv( aItem[1], aItem[1] } )
Copy from a logged into HbNetIO server a file to LeoDBf located in RAM:
Leto_FCopyToSrv( "net:hbnetio.txt", "mem:RAMfile.txt" )
Amiguinhos,
Voces conseguiram alguma coisa.
Gsotariam de compartilhar. Estou na peleja e não obtive êxito ao testar hbNetIO.
Para colocar as bases em modo servidor bastará ativar o DBF Server Lights e jogar as tabelas na pasta interna DATA.
Ao testar com hbNetIO do Harbour 3.1 até revisão 17025 obtive corrupção dos data inutilizando a tabela.
Ao usar com hbNetIO do Harbour 3.1, revisão 17222 o programa trava logo na conecção e não segue em frente até que aconteça stop no DBF Server Lights.
Ao linkar apenas adicionei a hbNetIO.lib e não usei modo console.
Usuários vendo este fórum: Nenhum usuário registrado online e 19 visitantes