Hello Mil Service is started now on win2003, Now i am using the createthread and waitforsingleobject. There is no memory error but now i got one more problem it is giving me the clinet Socket error from the function below. I don't know what is the problem now i did not change any part of code for client request. can u suggest me something. UINT ClientThread(LPVOID pParam) { char buff[MAX_BUFFER_LENGTH]; CString cmd; CString params; int n; BOOL auth=false; SOCKET client=(SOCKET)pParam; // send(client,buff,strlen(buff),0); int nCounter = 0; CString strData; CString strFileName; SYSTEMTIME sysTime; while(true) { n=recv(client,buff,MAX_BUFFER_LENGTH,0); if(n==SOCKET_ERROR ) { WriteToLog("Client Socket Error"); break; } if(n == 0) { //continue; //if no data recieve exit the loop and close the connection and Client Thread break; } buff[n]=0; params = (char*)buff; if(nCounter == 0) { nCounter += n; WriteToLog((LPSTR)(LPCTSTR)params); GetLocalTime(&sysTime); strFileName.Format("%s\\User%d%d%d%d%d%d%d.xml",DataFolder,sysTime.wMonth,sysTime.wDay ,sysTime.wYear ,sysTime.wHour ,sysTime.wMinute ,sysTime.wSecond ,sysTime.wMilliseconds ); if(!xmlFile.Open(strFileName,CFile::modeWrite | CFile::modeCreate,NULL)) { errorMsg.Format("Unable to create %s file",strFileName); WriteToLog((LPSTR)(LPCTSTR)errorMsg); } int nRetVal = params.Find(";",0); if(nRetVal != -1) { cmd = params.Left(nRetVal); if(n > nRetVal) { strData = params.Mid(nRetVal + 1); { LPSTR lpstr = (LPSTR)(LPCTSTR)(strData); xmlFile.Write((PVOID)lpstr,strlen(lpstr)); } } }//end nRetVal else { // USES_CONVERSION; LPSTR lpstr = (LPSTR)(LPCTSTR)(params); xmlFile.Write((PVOID)lpstr,strlen(lpstr)); } if(params.Find(ENDXMLTAG) != -1) { xmlFile.Close (); nCounter = 0; ExecuteDosent(cmd,strFileName); cmd.MakeUpper(); if(cmd.Compare("DRUSER")) ExecuteInvokeBat(strFileName); //break; } }//End nCounter else { nCounter += n; LPSTR lpstr = (LPSTR)(LPCTSTR)(params); xmlFile.Write((PVOID)lpstr,strlen(lpstr)); if(params.Find(ENDXMLTAG) != -1) { xmlFile.Close (); nCounter = 0; WriteToLog((LPSTR)(LPCTSTR)params); ExecuteDosent(cmd,strFileName); cmd.MakeUpper(); if(cmd.Com