|
What about data coming FROM the server to the client? Are you relaying all that data too?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Yes, i do reply, when i receive any message from one of them i put it into related queue then forward it
i don't know much about MySQL server communication protocol may it be related with this?
i only want to send all packages from one gate to another gate (and reverse) that's all
|
|
|
|
|
I see you've closed the project but if you were looking at "messages" as they passed through
then you'd need to know everything about the message protocol. Otherwise every byte should
be passed through untouched.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
We've closed this project coz it's much complex for a single project's single leaf
we've agreed to use a PROXY server to solve this problem
|
|
|
|
|
I've created a static global variable, "static int m_foo", in stdafx.h in my MFC project.
Then I change the value of m_foo in the FooMainFrm.cpp file.
Whenever I query m_foo, in any of the other modules, I find its state reinitialized to zero.
Using the "extern" keyword at the top of each of the modules doesn't help.
What's going on here?
|
|
|
|
|
werpa wrote: Using the "extern" keyword at the top of each of the modules doesn't help
did put the extern keyword on every cpp files that use it, or all but one ?
anyway, global variables don't need to be static AFAIK.
and at last, why going global ? can't you incorporate your variable as a class member (public static if you like) ?
|
|
|
|
|
I put "extern" in the modules that used the varialbes. I didn't put it in the ones that didn't use the variable. I am incorporating the variable into a class where it doesn't precisely fit in order to have its global and static reach.
|
|
|
|
|
werpa wrote: I am incorporating the variable into a class where it doesn't precisely fit in order to have its global and static reach.
Sounds like it might belong in your CWinApp -derived class.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Assuming that static specifies that m_foo is not visible from outside stdafx.h , what if you remove the static qualifier?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I need to make it "static" in order to keep from getting fatal LNK1169 error "one or more multiply defined symbols found"
|
|
|
|
|
werpa wrote: error "one or more multiply defined symbols found"
this is normally solved using extern, not static, no ?
my bad, David got it right. you must use exclusive statement macros
|
|
|
|
|
werpa wrote: I need to make it "static" in order to keep from getting fatal LNK1169 error "one or more multiply defined symbols found"
Something is amiss with your stdafx.h file. It should resemble:
#if !defined(STDAFX_H)
#define AFX_STDAFX_H
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define _WIN32_WINNT 0x0500
int m_foo;
#endif
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks for your good thoughts.
I made these changes but still need "static" to keep from getting LNK1169.
|
|
|
|
|
werpa wrote: I made these changes but still need "static" to keep from getting LNK1169.
You are simply addressing the symptom and not the underlying cause. Find all declarations of m_foo . The one in stdafx.h should be declared as:
int m_foo; and all others should be declared as:
extern int m_foo; You'll find that Nemanja's suggestion is a bit cleaner, though, as it only requires changing two files.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
That worked great to get rid of the LNK1169. (I put it the extern everywhere!) Now, however, it comes back if I set the value or query it. As long as I don't use the value in the module the error stays away. The minute I add it to the module, I get it back.
|
|
|
|
|
Isn't that reversed?
Shouldn't the extern declaration be in the header and ONE "int m_foo;" instance be in a cpp
module somewhere?
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
nope.
by doing what Nemanja suggested, every cpp file actually includes the extern declaration (so, don't define the variable, and assume that it is defined elsewhere), and stdafx.cpp is the exception, by actually declaring the global variable.
oh my !
forget it
|
|
|
|
|
Goofball
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I tried it both ways and it worked the same. Since the header file looked like this, the variable was only declared once.
Like I said, Nemanja's way is cleaner as it only involves two changes, rather than multiple changes depending on how many places use the "global" variable.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OK I assumed stdafx was used in the normal way - as a PCH included in every module. Which
would make a separate instance for every module, right?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
This will produce link errors because every .CPP file will have a definition of the variable m_foo .
Steve
|
|
|
|
|
Stephen Hewitt wrote: This will produce link errors...
It doesn't.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Are we talking about the same thing? It seems it does[^].
Steve
|
|
|
|
|
There's probably no link error because the scope of each m_foo is contained to each cpp module.
The real problem that I see is that it's not a single global variable.
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
In stdafx.h:
extern int foo;
And, in stdafx.cpp:
int foo;
|
|
|
|