Hello,
I am trying to write a windows service that is monitoring the health of a program that uses port 443. I thought the best way to monitor the program is to try to open a socket on 443, if it cannot, then my program is either not responding or not running, at which point I have to recover my program.
So, I am trying to implement a service to open a socket and listen on this port. However, the code I have written below is trying to open a command window to give me an error, but my service is a console app that is a service and does not allow windows to be created.
Can someone pls tell me what i'm doing wrong or can you explain how to open a socket on a lower-level?
thanks in advance,
bool CMYSocket::GETSocket()
{
TCHAR buffer[256];
CAsyncSocket* pSocket = new CAsyncSocket;
int nPort = 443;
WSADATA WsaData;
if (!AfxSocketInit ( &WsaData))
{
//could not init
return FALSE;
}
if (pSocket->Create( nPort, SOCK_DGRAM ) == 0)
{
DWORD dwErr = GetLastError();
// blah blah do something here
}
else
{
pSocket->Close();
return true;
}
return true;
}
I am trying to write a windows service that is monitoring the health of a program that uses port 443. I thought the best way to monitor the program is to try to open a socket on 443, if it cannot, then my program is either not responding or not running, at which point I have to recover my program.
So, I am trying to implement a service to open a socket and listen on this port. However, the code I have written below is trying to open a command window to give me an error, but my service is a console app that is a service and does not allow windows to be created.
Can someone pls tell me what i'm doing wrong or can you explain how to open a socket on a lower-level?
thanks in advance,
bool CMYSocket::GETSocket()
{
TCHAR buffer[256];
CAsyncSocket* pSocket = new CAsyncSocket;
int nPort = 443;
WSADATA WsaData;
if (!AfxSocketInit ( &WsaData))
{
//could not init
return FALSE;
}
if (pSocket->Create( nPort, SOCK_DGRAM ) == 0)
{
DWORD dwErr = GetLastError();
// blah blah do something here
}
else
{
pSocket->Close();
return true;
}
return true;
}