Page 1 of 1

getip() returen 0.0.0.0

PostPosted: Tue May 06, 2014 9:25 pm
by Patricio Avalos Aguirre
Estimados

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

adjunto la funcion

Code: Select all  Expand view
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 );
}

 

Re: getip() returen 0.0.0.0(RESUELTO)

PostPosted: Mon May 12, 2014 5:05 pm
by Patricio Avalos Aguirre
Estimados

lo he resuelto con la funcion

GetNetCardInfo()

Re: getip() returen 0.0.0.0

PostPosted: Wed May 14, 2014 8:56 am
by Antonio Linares
gracias por compartirlo :-)

Re: getip() returen 0.0.0.0

PostPosted: Thu May 15, 2014 2:37 pm
by lubin
Buen dia Patricio
Una consulta, De donde puedo bajar esa funcion GetNetCardInfo(), pues al compilar me sale error

Gracias

Lubin

Re: getip() returen 0.0.0.0

PostPosted: Thu May 15, 2014 3:32 pm
by karinha
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.

Re: getip() returen 0.0.0.0

PostPosted: Thu May 15, 2014 4:21 pm
by lubin
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

Re: getip() returen 0.0.0.0

PostPosted: Thu May 15, 2014 5:32 pm
by karinha