i try to get the ip address from a file and then make socket and send info, i want to send same info to same ip twice so i put ip "127.0.0.1" twice in the text file, but it sends info only once. here is the code ----
#include <windows.h>
#include <winsock.h>
#include <stdio.h>
#include <lm.h>
#include <tchar.h>
#include <wchar.h>
#include <iostream>
#define NETWORK_ERROR -1
#define NETWORK_OK 0
short int c = 1;
void ReportError(int, const char *);
void printServ();
int sockpro();
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow)
{
while(1)
{
printServ();
Sleep(1000);
}
return 0;
}
void ReportError(int errorCode, const char *whichFunc)
{
char errorMsg[92]; // Declare a buffer to hold
// the generated error message
ZeroMemory(errorMsg, 92); // Automatically NULL-terminate the string
// The following line copies the phrase, whichFunc string, and integer errorCode into the buffer
sprintf_s(errorMsg, "Call to %s returned error %d!", (char *)whichFunc, errorCode);
MessageBoxA(NULL, errorMsg, "socketIndication", MB_OK);
}
//to print the state of required process on the server
void printServ()
{
SC_HANDLE hSCM;
SERVICE_STATUS ss;
short int j, x;
x = 1; //Number of services.
//Services to be checked.
wchar\_t\* prName\[\] = {
\_T("W3SVC"), //World Wide Web Publishing service
};
for(j=0; j<x ; j++)
{
//OpenSCManager establishes a connection to the service control manager on the specified computer
//and opens the specified service control manager database and return value is a handle to the specified
//service control manager database.
hSCM = OpenSCManager
(
NULL, //Name of the target computer.
SERVICES\_ACTIVE\_DATABASE, //Name of the service control manager database, optional.
SC\_MANAGER\_CONNECT //Access right to the service control manager.
);
if (hSCM != NULL)
{
//OpenService opens an existing service and the return value is a handle to the service.
SC\_HANDLE hService = OpenService