Harbour Funções Novas! Via TCP/IP

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Harbour Funções Novas! Via TCP/IP

Mensagem por Itamar M. Lins Jr. »

Ola!
Finalmente o Przemek terminou as prometidas funções para usarmos via protocolo TCP.

Código: Selecionar todos


hb_xRead("127.0.0.1:2941",FO_NORMAL)...
ou
pSocket    := hb_XOpen( "tcp:127.0.0.1:2941", FO_READWRITE )
pGZipPipe := hb_XOpen( "|gzip > data.gz", FO_WRITE )
pFtp         := hb_XOpen( "ftp:user:pass@192.168.1.12:/pub/archive.tgz",FO_READ )
Um novo horizonte se abre aos Harbourianos!
+ added PRG interface to Harbour FILE IO API
The following PRG functions are available for Harbour programmers:
HB_XEXISTS( <cFileName>, [ @<cDestFileName> ] ) -> <lOK>
HB_XERASE( <cFileName> ) -> <nResult>
HB_XRENAME( <cFileSrc>, <cFileDst> ) -> <nResult>
HB_XCOPYFILE( <cFileSrc>, <cFileDst> ) -> <nResult>
HB_XDIREXISTS( <cDirName> ) -> <lExists>
HB_XDIRMAKE( <cDirName> ) -> <nSuccess>
HB_XDIRREMOVE( <cDirName> ) -> <nSuccess>
HB_XDIRECTORY( [ <cDirSpec> ], [ <cAttr> ] ) -> <aDirectory>
HB_XDIRSPACE( <cDirName>, [ <nInfoType> ] ) -> <nFreeSpace>
HB_XGETATTR( <cFileName>, @<nAttr> ) -> <lOK>
HB_XSETATTR( <cFileName>, <nAttr> ) -> <lOK>
HB_XGETDATETIME( <cFileName>, @<tsDateTime> ) -> <lOK>
HB_XSETDATETIME( <cFileName>, <tsDateTime> ) -> <lOK>
HB_XLINK( <cExistingFileName>, <cNewFileName> ) -> <nSuccess>
HB_XLINKSYM( <cTargetFileName>, <cNewFileName> ) -> <nSuccess>
HB_XLINKREAD( <cFileName> ) -> <cDestFileName> | ""
HB_XOPEN( <cFileName>, [ <nMode> ], [ <nAttr> ] ) -> <pHandle> | NIL
HB_XCLOSE( <pHandle> ) -> <lOK>
HB_XLOCK( <pHandle>, <nStart>, <nLen>, [ <nType> ] ) -> <lOK>
HB_XUNLOCK( <pHandle>, <nStart>, <nLen> ) -> <lOK>
HB_XLOCKTEST( <pHandle>, <nStart>, <nLen>, [ <nType> ] ) ;
-> <nPID> | 0 (nolock) | -1 (err)
HB_XREAD( <pHandle>, @<cBuff>, [ <nToRead> ], [ <nTimeOut> ] ) ;
-> <nRead>
HB_XWRITE( <pHandle>, <cBuff>, [ <nToWrite> ], [ <nTimeOut> ] ) ;
-> <nWritten>
HB_XREADAT( <pHandle>, @<cBuff>, [ <nToRead> ], [ <nAtOffset> ] ) ;
-> <nRead>
HB_XWRITEAT( <pHandle>, <cBuff>, [ <nToWrite> ], [ <nAtOffset> ] ) ;
-> <nWritten>
HB_XSEEK( <pHandle>, <nOffset>, [ <nWhence> ] ) -> <nOffset>
HB_XTRUNC( <pHandle>, [ <nAtOffset> ] ) -> <lOK>
HB_XSIZE( <pHandle> ) -> <nSize>
HB_XEOF( <pHandle> ) -> <lEOF>
HB_XFLUSH( <pHandle>, [ <lDirtyOnly> ] ) -> NIL
HB_XCOMMIT( <pHandle> ) -> NIL
HB_XCONFIG( <pHandle>, <nSet>, [ <nParam> ] ) -> <nResult>
HB_XHANDLE( <pHandle> ) -> <nOsHandle>
HB_XTEMPFILE( @<cFileName>, [ <cDir> ], [ <cPrefix> ], [ <cExt> ], ;
[ <nAttr> ] ) -> <pHandle> | NIL
Please remember that not all redirectors have to support all of them.
I.e. MEMIO allows to use directory names in files but does not allow to
create or remove directories. It also does not support file attributes
and times in current implementation though it can be easy added.
HB_XCONFIG() is general function which can be used by redirector
authors to make some special operations which are specific to given
device.
HB_XTEMPFILE() always creates temporary files on local system without
switching to FILE IO redirector. It's intentional behavior.

* src/rtl/fscopy.c
* used Harbour FILE IO API in hb_fsCopy()/HB_FCOPY()
Please remember that HB_FCOPY() always makes operation using current
system when HB_XCOPY() may optimize it moving the operation to low
level subsystem or even other computer i.e. NETIO can do that when
both files are located on the same server.

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Harbour Funções Novas! Via TCP/IP

Mensagem por Itamar M. Lins Jr. »

Outro exemplo bem interessante.

Código: Selecionar todos

These functions work like corresponding F*() ones but can be
redirected to different devices/computers using contrib or 3-rd
party libraries, i.e. files with "MEM:" prefix are redirected
by HBMEMIO to memory filesystem and files with "NET:" prefix
are redirected by HBNETIO to HBNETIO servers on other computers,
i.e.:

   REQUEST HB_MEMIO, NETIO_CONNECT

   hb_XCopy( "table.dbf", "MEM:table.dbf" )
   use "MEM:table"
   copy to NET:192.168.1.10:table
   hb_XDirMake( "NET:192.168.1.10:bak" )
   hb_XCopy( "NET:192.168.1.10:table.dbf", "NET:192.168.1.10:bak/table" )

on computer 192.168.1.10 you should run NETIO to make above code working.
It's possible to write many different redirectors, i.e. for "TCP:" prefix
we can open TCP sockets. Someone may add support for upper level protocols
like FTP or HTTP using corresponding prefixes. Some other redirector may
detect pipe character "|" at the beginning and at the end of file name and
open process with redirected stdin/stdout, etc.
É mole ? Copiar/backup por TCP dessa forma ?

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Harbour Funções Novas! Via TCP/IP

Mensagem por JoséQuintas »

E se isso expandir mais talvez chegasse a use ("http://www.site.com.br/arquivo.dbf" ) READONLY

Só resta saber se tem os mesmos problemas da hbtip, se é que precisa da hbtip pra isso.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7929
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

Harbour Funções Novas! Via TCP/IP

Mensagem por Itamar M. Lins Jr. »

Ola!
Só resta saber se tem os mesmos problemas da hbtip, se é que precisa da hbtip pra isso.
Quais são esses problemas da HBTIP ?

Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

Harbour Funções Novas! Via TCP/IP

Mensagem por JoséQuintas »

Esquece... Não sei dizer se ainda acontece.
Não achei isso no meu changelog, acho que estou no Harbour errado.
Putz... diferença pro manual... rs
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
runner
Usuário Nível 2
Usuário Nível 2
Mensagens: 69
Registrado em: 03 Ago 2007 05:17
Localização: GUARULHOS-SP

Harbour Funções Novas! Via TCP/IP

Mensagem por runner »

Olá, Pessoal.


Muito bom este material e justamente o que preciso, hehehehehe

Runner
Harbour 3.2 + Minigui Extended 16 + xDev
Abel
Usuário Nível 3
Usuário Nível 3
Mensagens: 332
Registrado em: 14 Mar 2012 13:16
Localização: sao paulo / sp

Harbour Funções Novas! Via TCP/IP

Mensagem por Abel »

ola, vi estas funcoes mas nao entendi.

seria possivel com elas, fazer um backup e jogar nas nuvens ?

Abracos
ABEL
Responder