Página 1 de 1

Harbour Funções Novas! Via TCP/IP

Enviado: 25 Fev 2014 18:24
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.

Harbour Funções Novas! Via TCP/IP

Enviado: 25 Fev 2014 18:37
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.

Harbour Funções Novas! Via TCP/IP

Enviado: 25 Fev 2014 21:00
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.

Harbour Funções Novas! Via TCP/IP

Enviado: 07 Mar 2014 13:32
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.

Harbour Funções Novas! Via TCP/IP

Enviado: 07 Mar 2014 15:28
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

Harbour Funções Novas! Via TCP/IP

Enviado: 21 Mar 2014 14:25
por runner
Olá, Pessoal.


Muito bom este material e justamente o que preciso, hehehehehe

Runner

Harbour Funções Novas! Via TCP/IP

Enviado: 24 Ago 2014 20:17
por Abel
ola, vi estas funcoes mas nao entendi.

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

Abracos
ABEL