Page 1 of 2
Network connection
Posted: Thu Sep 13, 2007 11:48 pm
by cdmmaui
Is it possible to confirm connection to network withing FWPPC?
Posted: Fri Sep 14, 2007 10:52 am
by Antonio Linares
Darrell,
If you mean local network, then you may check for a file existence:
if File( "\\machine\path\filename" )
For Internet access, you may use:
Function IsInternet()
WSAStartup()
RETURN GetHostByName( "
www.microsoft.com" ) != "0.0.0.0"
Posted: Fri Sep 14, 2007 12:17 pm
by cdmmaui
Thank you Antonio
Posted: Fri Sep 14, 2007 1:56 pm
by cdmmaui
Antonio,
I got a FWPPC GPF occurred. Fix GPFStack() when using IsInternet function below.
Posted: Fri Sep 14, 2007 2:00 pm
by cdmmaui
Antonio,
The GPF was caused by the WSAStartup() function. I removed it and I did not get the GPF. Is this function required?
Posted: Fri Sep 14, 2007 2:07 pm
by Antonio Linares
Darrell,
Is IsInternet() working without it ?
Posted: Fri Sep 14, 2007 2:11 pm
by cdmmaui
Hi Antonio,
No, it returns IP 0.0.0.0; however the internet is working and my FWPPC application sees host \\cargo\data. Should GetHostByName() use 'cargo' or '\\cargo'?
Thank you,
Posted: Fri Sep 14, 2007 2:16 pm
by Antonio Linares
"\\" is just for other machines on the LAN.
Please add this code to your PRG:
Code: Select all
#pragma BEGINDUMP
#include <hbapi.h>
#include <WinSock2.h>
HB_FUNC( WSASTARTUP )
{
static WSADATA wsa;
hb_retni( WSAStartup( 0x202, &wsa ) );
}
#pragma ENDDUMP
Posted: Fri Sep 14, 2007 2:22 pm
by cdmmaui
Antonio,
Got the following error when trying to build application.
FiveCEC.lib(WINSOCK.obj) : error LNK2005: HB_FUN_WSASTARTUP already defined in CDM-NET.obj
FiveCEC.lib(WINSOCK.obj) : warning LNK4006: HB_FUN_WSASTARTUP already defined in CDM-NET.obj; second definition ignored
Creating library CDM-NET.lib and object CDM-NET.exp
CDM-NET.exe : fatal error LNK1169: one or more multiply defined symbols found
Posted: Fri Sep 14, 2007 2:44 pm
by Antonio Linares
Darrell,
use this flag for link.exe: /force:MULTIPLE
Posted: Fri Sep 14, 2007 3:43 pm
by cdmmaui
Antonio,
I am getting a fatal application error.
Posted: Fri Sep 14, 2007 5:30 pm
by Antonio Linares
Darrel,
What FWPPC build are you using ? Please tell me the dates of the libraries, thanks
Posted: Fri Sep 14, 2007 5:57 pm
by cdmmaui
fivece.lib 08/26/2007 @ 23:24
fivecec.lib 08/26/2007 @ 23:20
Posted: Fri Sep 14, 2007 6:15 pm
by Antonio Linares
Darrell,
This Test.prg works fine here with no GPFs. Please try it, thanks:
Code: Select all
function Main()
MsgInfo( IsInternet() )
return nil
Function IsInternet()
WSAStartup()
RETURN GetHostByName( "www.microsoft.com" ) != "0.0.0.0"
Re: Network connection
Posted: Sat May 23, 2009 6:37 pm
by Otto
Hello Antonio,
this solution is working but if there is no network you get for a very long time a frozen systembefore an error is returned.
Many useres press the reset button because they think the system is gone down.
Maybe there is a better solution?
Thanks in advance
Otto
If you mean local network, then you may check for a file existence:
if File( "\\machine\path\filename" )