FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour getip() returen 0.0.0.0
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
getip() returen 0.0.0.0
Posted: Tue May 06, 2014 09:25 PM
Estimados

La funcion GetIp() return 0.0.0.0 cuando la direccion es estatica, hay alguna manera de repararlo

adjunto la funcion

Code (fw): Select all Collapse
HB_FUNC( GETIP ) // nSocket
{
   SOCKADDR_IN sa;
   int iLen = sizeof( sa );
   BYTE addr[ 20 ];
   #ifdef UNICODE
      LPWSTR pW1, pW2;
   #endif   

   memset( ( char * ) &sa, 0, sizeof( sa ) );
   getsockname( hb_parni( 1 ), ( SOCKADDR * ) &sa, &iLen );
   strcpy( ( char * ) addr, "error" );

   #ifndef UNICODE
      wsprintf( ( char * ) addr, "%i.%i.%i.%i",
                ( BYTE ) sa.sin_addr.s_net, ( BYTE ) sa.sin_addr.s_host,
                ( BYTE ) sa.sin_addr.s_lh, ( BYTE ) sa.sin_addr.s_impno );
   #else
      pW1 = AnsiToWide( ( char * ) addr );             
      pW2 = AnsiToWide( "%i.%i.%i.%i" );
      wsprintf( pW1, pW2,
                ( BYTE ) sa.sin_addr.s_net, ( BYTE ) sa.sin_addr.s_host,
                ( BYTE ) sa.sin_addr.s_lh, ( BYTE ) sa.sin_addr.s_impno );
      hb_xfree( pW1 );
      hb_xfree( pW2 );
   #endif         

   hb_retc( ( char * ) addr );
}
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: getip() returen 0.0.0.0(RESUELTO)
Posted: Mon May 12, 2014 05:05 PM
Estimados

lo he resuelto con la funcion

GetNetCardInfo()
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: getip() returen 0.0.0.0
Posted: Wed May 14, 2014 08:56 AM

gracias por compartirlo :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 467
Joined: Fri Dec 09, 2005 12:41 AM
Re: getip() returen 0.0.0.0
Posted: Thu May 15, 2014 02:37 PM

Buen dia Patricio
Una consulta, De donde puedo bajar esa funcion GetNetCardInfo(), pues al compilar me sale error

Gracias

Lubin

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: getip() returen 0.0.0.0
Posted: Thu May 15, 2014 03:32 PM
lubin wrote:Buen dia Patricio
Una consulta, De donde puedo bajar esa funcion GetNetCardInfo(), pues al compilar me sale error

Gracias

Lubin



C:\FWH..\SAMPLES\GETMAC.PRG

salu2.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 467
Joined: Fri Dec 09, 2005 12:41 AM
Re: getip() returen 0.0.0.0
Posted: Thu May 15, 2014 04:21 PM

Gracias Patricio

Pero lamentablemente :oops: creo que mi version no la incluye, no cuento con esa carpeta en Samples,

Alguna otra alternativa usando harbour

Lubin

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: getip() returen 0.0.0.0
Posted: Thu May 15, 2014 05:32 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion