|
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.Compare("DRUSER"))
ExecuteInvokeBat(strFileName);
//break;
}
}
}//end of while
closesocket(client);
return 0;
}
thanks
shailesh
|
|
|
|
|
Hello, some day, i was reading "tips and tricks for windows 98" and found a tip that says "do you know that regedit.exe runs also in dos?"
I tought "what? thats not possible!" But then i restarted in ms-dos mode and run regedit.exe. It was really running. I have already posted this problem to
this site
and i wont write it here all over again. If you vould be so kind and look at the link? It seems that they cant help me on that site. I hafe found a lot of info from when i firstly posted the question, but there is still that unanswered question: "How can i tell my compiler to build the dos stub from my code?"
THANKS, PLEASE REPLY
Sorry for my English grammar, I am from Slovakia.
By the way, if you find that you are unable to read those sentences by me, please take a look at theese pictures on my site:
The classic PE file
Regedit.exe (custom stub)
Thanks,
vilo999
|
|
|
|
|
Vilo999 wrote:
How can i tell my compiler to build the dos stub from my code?"
I'm not sure exactly what you mean by this, but you can use any DOS program as your program stub by using the "/STUB:<filename>" command line option. The program must be an .EXE file (it can't be a .COM file) and must be a pure DOS program.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
How could i forgot to check the linker options...
Thanks for your help it works perfect!
|
|
|
|
|
Vilo999 wrote:
It seems that they cant help me on that site.
Didn't you post on August 25, 2004 @ 3:34 PST that the problem was solved?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am trying to use a CScrollView class in my app. I am drawing text on the view using DrawText. The problem I am having is that when I resize the window smaller, then scroll down, the text that should be at the bottom of the window doesn't appear. It's just blank. Changing the value to SetScrollSizes changes the behavior, but I can't get it to work right. Any help would be appreciated!!
|
|
|
|
|
I instantiate a structure in my initial dialog box, but wish to gain access to that particular instance of the structure in another dialog box. How do I get access to that structure variables from a class other than the one I created it in?
David
|
|
|
|
|
You need fundamentals of C/C++ programming. Things like "variable scope" and "pointers". There are many sources on the internet but books can frequently be the best learning tool for beginners.
Watch out! I'm a CPian on the edge!
I have a new Gold rating and I'm not afraid to use it! -pete
|
|
|
|
|
I have a function that accepts a 'pointer to an int' as a parameter. In my code I call this function and pass to it the address of the variable. However, the variable at this address is an unsigned short. How do I cast this to an int since my function needs a 'pointer to an int'?
class Foo{
void Function(int *A);
}
Foo.Function(&Element[22]);
|
|
|
|
|
Foo.Function((int *) &Element[22]);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Yes but you better make sure the system you are on they are both the same storage width otherwise strong bad could ensue.
Watch out! I'm a CPian on the edge!
I have a new Gold rating and I'm not afraid to use it! -pete
|
|
|
|
|
|
What do you mean same storage width? Maybe that is why I am having difficulty getting the right value for what is in that address. I did exactly what was suggested but did not get the result I expected. I expect a value of 0 but now I get some huge number... Do you know why? Thanks!
|
|
|
|
|
It turns out that it is grabbing the value at &Element[22] and &Element[23] when i only want the value at &Element[22]. But I cannot change the function's parameter because it is called from other classes that do pass 'pointer to int' values. In Foo.Function(int *A) I have:
{
int value;
value = A[0];
...
...
}
A[0] becomes what is in Element[23]... it should be Element[22]. Is there something wrong? Although A[1] would contain the value I want, it does not make sense to change it so. What should I do?
|
|
|
|
|
The following should work. You create a variable that is the correct size, and the compiler should do the conversion correctly, then pass a pointer to that. Basicly the compiler cannot assume you don't know what you are doing when you cast things around.
MyFunct() {
int tmpValue;
short myArray[SIZE];
...
tmpValue = myArray[position];
otherFunct(&tmpValue);
myArray[position] = tmpValue;
...
}
|
|
|
|
|
Thanks! I did exactly that and you confirmed my solution. (I don't think I need that last line of code right?)
|
|
|
|
|
I don't know if you need that last line or not. If the function has const declarded in the right place (without a book to check I'm not going to say more lest I get it wrong) you don't. If the function will change the value you pass in (and why else take a pointer to an int?) then you need that last line if you want to save the change. It is your call though, as only you know what the data represents.
|
|
|
|
|
I am making a game called Champions. I do not know anything about C++ I need to know exactly how to connect to mysql database through DLL files plus I'll need to know what to type into the DLL files.
in table1 I have 3 columns for info: 1st column is Username, 2nd is password, and 3rd is status(tells what type of user he/she is)
in table2 I will have 10 columns for info: 1st is name(character's name), 2nd is username, 3rd is con, 4th is dex, 5th is str, 6th is intel, 7th is cha, 8th is wis, 9th is race, and 10th is class. I need to know how to control mysql database through C++ and DLL files. Remember I know knowing about C++. I also want to ask for an IP address to connect to before connecting because the IP address will change alot. have it connect to database on that IP address.
|
|
|
|
|
You want to talk to Christian Graus[^]. He has a system that does all that.
Watch out! I'm a CPian on the edge!
I have a new Gold rating and I'm not afraid to use it! -pete
|
|
|
|
|
Where can I get his system?
|
|
|
|
|
palbano is trying to make my life hell, because I am known to have a short fuse when people ask idiotic questions. If you know nothing about C++, why are you asking a question about it ? What are you writing your game in ? I suggest you use the same 'language' for your data layer, and if it can't handle that ( which is after all, a core thing that computers find easy to do ), ask yourself the odds of it creating a half decent game. MySQL is, in any case, crap. You may as well use Access. Either way, it sounds to me like you're lost at sea, and need to seriously evaluate what sort of project you're capable of taking on.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
palbano is trying to make my life hell
And you didn't even 5 me!
Sorry I couldn't resist. But I all but promise I will almost for sure, probably just about never do that again
Watch out! I'm a CPian on the edge!
I have a new Gold rating and I'm not afraid to use it! -pete
|
|
|
|
|
While I don't agree with Christian's approach, I do agree with his intent.
Linera wrote:
I do not know anything about C++ I need to know exactly how to connect to mysql database through DLL...
Remember I know knowing about C++. I also want to ask for an IP address to connect to before connecting because the IP address will change alot. have it connect to database on that IP address.
Why in the world would you want to use a language for which you know nothing about? What do you have against using C (or C++ if that's all you have access to) to make some "starter" programs with first? For example: converting fahrenheit to celcius and back, writing to and reading from a file, averaging numbers entered from the keyboard, calculating free/used space on all drives, etc. Get some of the basics out of the way before "diving into the deep end of the pool."
Linera wrote:
I also want to ask for an IP address to connect to before connecting because the IP address will change alot. have it connect to database on that IP address.
Since the IP address is subject to change, wouldn't it make more sense to use a host name instead and let DNS-lookup find the correct IP address, whatever it happens to be today?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
I've defined my own slider class, with a CONST max range value 10000.
When i press a button to retrieve it's value, it works fine(even with >100 values).
When i call OnHScroll, it's value never passes 100.
How do i make to retrieve bigger values in call of OnHScroll ?
Or is there any way to ovveride OnLButtonDown and OnLButtonUp, to be accessed by main window "OnLButtonDown and OnLButtonUp" (i tried to check if the mouse click is in slider's rect, but the app reports a click only if the slider is disabled).
Thanks alot for help in advance
|
|
|
|