Click here to Skip to main content
15,918,108 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralProblem getting openGL current screen Pin
imranlodhi25-Aug-04 19:50
imranlodhi25-Aug-04 19:50 
GeneralGet Video Card info, like getVolumeinfo Pin
Anonymous24-Aug-04 18:43
Anonymous24-Aug-04 18:43 
QuestionConnecting to Mysql database??? Pin
Linera24-Aug-04 18:09
Linera24-Aug-04 18:09 
AnswerRe: Connecting to Mysql database??? Pin
David Crow25-Aug-04 3:13
David Crow25-Aug-04 3:13 
Generalsearch function help Pin
CShoun24-Aug-04 17:05
CShoun24-Aug-04 17:05 
GeneralRe: search function help Pin
David Crow25-Aug-04 3:11
David Crow25-Aug-04 3:11 
GeneralAdd/Remove Programs Pin
Ed K24-Aug-04 15:17
Ed K24-Aug-04 15:17 
GeneralRe: Add/Remove Programs Pin
Graham Bradshaw25-Aug-04 3:09
Graham Bradshaw25-Aug-04 3:09 
GeneralRe: Add/Remove Programs Pin
Ed K25-Aug-04 5:14
Ed K25-Aug-04 5:14 
GeneralRe: Add/Remove Programs Pin
David Crow25-Aug-04 3:20
David Crow25-Aug-04 3:20 
GeneralC++ dialog question Pin
Linera24-Aug-04 14:22
Linera24-Aug-04 14:22 
GeneralRe: C++ dialog question Pin
Ravi Bhavnani24-Aug-04 15:02
professionalRavi Bhavnani24-Aug-04 15:02 
GeneralRe: C++ dialog question Pin
Linera24-Aug-04 15:12
Linera24-Aug-04 15:12 
GeneralRe: C++ dialog question Pin
ThatsAlok24-Aug-04 21:32
ThatsAlok24-Aug-04 21:32 
GeneralRe: C++ dialog question Pin
Rajesh match24-Aug-04 20:17
Rajesh match24-Aug-04 20:17 
GeneralRe: C++ dialog question Pin
Linera25-Aug-04 8:06
Linera25-Aug-04 8:06 
GeneralRe: C++ dialog question Pin
Rajesh match25-Aug-04 19:15
Rajesh match25-Aug-04 19:15 
GeneralRe: C++ dialog question Pin
Linera26-Aug-04 7:20
Linera26-Aug-04 7:20 
GeneralCreateProcess question... Pin
RobJones24-Aug-04 13:51
RobJones24-Aug-04 13:51 
GeneralRe: CreateProcess question... Pin
Archer28224-Aug-04 16:30
Archer28224-Aug-04 16:30 
GeneralRe: CreateProcess question... Pin
RobJones25-Aug-04 4:02
RobJones25-Aug-04 4:02 
GeneralWindow Service Question Pin
aman200624-Aug-04 13:46
aman200624-Aug-04 13:46 
hi
I wrote a window service in which i am using the SOCKET API who listens to the clinet. This service runs fine on win2000 but if i run this on win2003 Server, it stop with some access violation error c0000005. I don't know whats is the problem. If i run my code without service means i make the console application and run this it does not show any error on win2003. I have this code like:

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{

int nRetCode = 0;

if(FillParams())
_chdir(DIR_PATH);
else
return 0;

SERVICE_TABLE_ENTRY ServiceTable[2];
ServiceTable[0].lpServiceName = "TibcoTCPServer";
ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION)ServiceMain;
ServiceTable[1].lpServiceName = NULL;
ServiceTable[1].lpServiceProc = NULL;

// Start the control dispatcher thread for our service
StartServiceCtrlDispatcher(ServiceTable);

return nRetCode;
}

void ServiceMain(int argc, char** argv)
{

int error;


ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
// SERVICE_WIN32_SHARE_PROCESS;// SERVICE_WIN32;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
ServiceStatus.dwWin32ExitCode = 0;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwWaitHint = 0;

hStatus = RegisterServiceCtrlHandler(
"TibcoTCPServer",
(LPHANDLER_FUNCTION)ControlHandler);
if (hStatus == (SERVICE_STATUS_HANDLE)0)
{
// Registering Control Handler failed
WriteToLog("Registring Control Handler failed");
return;
}
// Initialize Service
error = InitService();
if (error)
{
// Initialization failed
ServiceStatus.dwCurrentState =
SERVICE_STOPPED;
ServiceStatus.dwWin32ExitCode = -1;
SetServiceStatus(hStatus, &ServiceStatus);
return;
}

// WriteToLog("Service Started _2.");

// We report the running status to SCM.
ServiceStatus.dwCurrentState = SERVICE_RUNNING;
SetServiceStatus (hStatus, &ServiceStatus);

AfxBeginThread(MTServerThread,0);


return;
}

UINT MTServerThread(LPVOID pParam)
{
WSADATA wsaData;
sockaddr_in local;

int wsaret=WSAStartup(0x101,&wsaData);
if(wsaret!=0)
{
return 0;
}
local.sin_family=AF_INET;
local.sin_addr.s_addr=INADDR_ANY;
int nPort = atoi(PORT);
local.sin_port=htons((u_short)nPort);
server=socket(AF_INET,SOCK_STREAM,0);
if(server==INVALID_SOCKET)
{
return 0;
}
if(bind(server,(sockaddr*)&local,sizeof(local))!=0)
{
return 0;
}
if(listen(server,SOMAXCONN)!=0)
{
return 0;
}

WriteToLog("Server Started.");
SOCKET client;
sockaddr_in from;
int fromlen=sizeof(from);

WriteToLog("Server Started _ 2.");

while(true)
{

WriteToLog("Server Started _ 3.");
client=accept(server,
(struct sockaddr*)&from,&fromlen);


WriteToLog("Client Request Accepted.");
AfxBeginThread(ClientThread,(LPVOID)client);

//Sleep(3000);

}

return 0;
}

It has the problem in MTServerThread() function when it comes in to the while loop. when it waits for the client at that point it throws the exception of access violation and stops the service.

Any input will be appreciated.

Thanks ina advance

Shailesh
GeneralRe: Window Service Question Pin
Milton Karimbekallil24-Aug-04 18:58
Milton Karimbekallil24-Aug-04 18:58 
GeneralRe: Window Service Question Pin
Stlan25-Aug-04 1:27
Stlan25-Aug-04 1:27 
GeneralRe: Window Service Question Pin
aman200626-Aug-04 7:42
aman200626-Aug-04 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.