Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extended stored procedure difficulties

Status
Not open for further replies.

wduty

Programmer
Jun 24, 2000
271
US
I have an extended-stored-procedure dll inside of which I am connecting to the internet with wininet function calls. It is very simple: the stored procedure causes a hit to a web page.

The problem is that I am behind a firewall and the connection only seems to work for addresses outside the firewall.

Furthermore, the exact same code does successfully hit addresses within the firewall if it is run from a standalone exe rather than a dll. So it seems like SQLServer is interfering with the networking code but I have no idea how.

Any suggestions appreciated.

Here is the dll:


RETCODE __declspec(dllexport) xp_hitweb1(SRV_PROC* srvproc)
{
DBSMALLINT i = 0;
DBCHAR spText[MAXTEXT];
DWORD dwTimeout;
PARM params;
HANDLE hThread;
DWORD dwThreadID;
ghOpen = NULL;
char* url;

if(!(url = (char*)srv_paramdata(srvproc, 1)))
{
srv_sendmsg(srvproc, SRV_MSG_ERROR, FAULTY_URL_ERROR, SRV_INFO, 1, NULL, 0, (DBUSMALLINT) __LINE__,
"missing parameter.", SRV_NULLTERM);
srv_senddone(srvproc, (SRV_DONE_ERROR | SRV_DONE_MORE), 0, 0);
return (XP_ERROR);
}


if(ghOpen = InternetOpen("test", LOCAL_INTERNET_ACCESS ,NULL, 0, 0))
{
params.pHost = url;
hThread = CreateThread(NULL, 0, Thd, &params, 0, &dwThreadID);
dwTimeout = 5000;

if (WaitForSingleObject(hThread, dwTimeout) == WAIT_TIMEOUT)
{
InternetCloseHandle (ghOpen);
WaitForSingleObject (hThread, INFINITE);
}
CloseHandle (hThread);
if (ghConnect)
{
/////////// Send a success message
wsprintf(spText, "remote hit");
srv_sendmsg(srvproc, SRV_MSG_INFO, 0, (DBTINYINT)0, (DBTINYINT)0, NULL, 0, 0, spText, SRV_NULLTERM);
InternetCloseHandle(ghConnect);
}
}
InternetCloseHandle(ghOpen);
srv_senddone(srvproc, SRV_DONE_MORE | SRV_DONE_COUNT, (DBUSMALLINT)0, (DBINT)i);
return XP_NOERROR ;
}

/////////////////// THREAD
DWORD WINAPI Thd(IN LPVOID vParams)
{
PARM* pParams;
pParams= (PARM*)vParams;
ghConnect = 0;
if (!(ghConnect = InternetOpenUrl(ghOpen, pParams->pHost, NULL, NULL, INTERNET_FLAG_RAW_DATA, NULL)))
return 1;
else return 0;
}

--Will Duty
wduty@radicalfringe.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top