|
WLAN is slower and more unreliable than wired LAN. Does your program work properly if datagrams are lost in transmission?
|
|
|
|
|
In 2K/XP therу is an option like "hide underlined letters for keyboard navigation until I press Alt Key". I'm interesting to know, which message is sent to controls when Alt pressed and controls redraw.
(sorry for bad english)
|
|
|
|
|
I believe it's WM_SYSKEYDOWN
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hi all
I have encountered a mysterious problem. When i tried to pass the CString argument, the compiler gives me the following error
ompiling...
Assignment3_question1Doc.cpp
e:\documents and settings\administrator\my documents\st2\mfc programming\assignment3_question1\assignment3_question1doc.h(23) : error C2629: unexpected 'class CString ('
Generating Code...
Compiling...
Assignment3_question1View.cpp
e:\documents and settings\administrator\my documents\st2\mfc programming\assignment3_question1\assignment3_question1doc.h(23) : error C2629: unexpected 'class CString ('
Generating Code...
Error executing cl.exe.
Assignment3_question1.exe - 3 error(s), 0 warning(s)
This is my class definition:
class Group
{
public:
Group(CString &t1, CString &t2, CString &t3, CString &t4)
{
team.Add(t1);
team.Add(t2);
team.Add(t3);
team.Add(t4);
}
CString GetTeam(int i)
{
return team.GetAt(i);
}
void PutResult(int t1, int s1, int t2, int s2)
{
}
void GetLadder()
{
}
private:
CStringArray team;
int res[4][4];
};
and this is how i used it
Group groupA(CString("France"), CString("Uruguay"), CString("Denmark"),CString("Senegal"));
and this is the MSDN says:
Compiler Error C2629
unexpected 'token ('
A syntax error made the statement ambiguous.
This error can be caused by mixing declaration and expression syntax.
The following is an example of this error:
class B
{
B( &B );
B( B& );
};
Note: I have inclulded the "Group.h" in the Document repository. This is a SDI , MFC application.
COuld you please enlighten me see where i went wrong. I have asked this couple of time but it sill give me the error.
Cheers.
|
|
|
|
|
Forget CString ("France"), just use "France". The conversion is implicit. I'm not sure, but I think pass by reference might be part of the problem ( although usually a great idea, I just have a feeling about it this time ). If you're going to pass bt reference as an optimisation, it's an excellent idea to make them const where-ever you don't intend to modify them.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Also CString implements reference counting and passing an object and not a reference will not produce much overhead at all.
Best regards,
Alexandru Savescu
|
|
|
|
|
tcuong,
Here is your code compiled in a Visual C++ console app with MFC support. I named the app 'Team'. The code works as you wrote it...
#include "stdafx.h"
#include "Team.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
class Group
{
public:
Group(CString &t1, CString &t2, CString &t3, CString &t4)
{
team.Add(t1);
team.Add(t2);
team.Add(t3);
team.Add(t4);
}
CString GetTeam(int i)
{
return team.GetAt(i);
}
void PutResult(int t1, int s1, int t2, int s2)
{
}
void GetLadder()
{
}
private:
CStringArray team;
int res[4][4];
};
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else
{
CString strHello;
strHello.LoadString(IDS_HELLO);
cout << (LPCTSTR)strHello << endl << endl;
Group groupA(CString("France"), CString("Uruguay"), CString("Denmark"),CString("Senegal"));
int i;
for(i = 0; i < 4; i++)
cout << (LPCTSTR)groupA.GetTeam(i) << endl;
cin >> i;
}
return nRetCode;
} The unexpected 'token (' error you are getting is a syntax error in your code ahead of the Group groupA(...) stuff. Try commenting out the Group groupA(...) line and see if the error moves to another line of code. If it does you definitely have a syntax error somewhere else. Email me your code if you still can't get it.
Good luck...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
I have a application that has serval CScrolledViews called.
There are plenty of good examples of how to add TabCtls to
the CMainFrame and I did that, But the "tabs" are on the
outside of my documents! How do I get them inside my documents
as the first "widget" inside the doc?
|
|
|
|
|
I have been given a task to develop a client server based application, a general purpose app that can deal with chatting and file transfer purposes.
I want to ask few questions in this regard. Please give me any suggestion regarding any of the question below:
1) The server should be able to deal "large" number of connections ie over 100,000 or above. What strategy should i follow ie socket or something else.
2) If i follow the socket strategy i've to use multithreading. My server will be deployed on single workstation running Win2K. How many threads can i make from a process in Win2k?? I don't want the processor to get heat up.
3) If i make a thread pool or use I/O completion ports, then will the server be able to handle over 100,000 connections of clients???
4) In order to deal with such a large number of connections, is it enough to deploy a server on single workstation or it it appropriate to run the servers on more than one workstations ???
5) Client should know the server address and a well known port to get connect. Now for server only one port will be monitoring the incoming requests for connections. Now is it a good idea that each thread of thread pool create its own port ???
|
|
|
|
|
I'm not sure about the technical side, but I'm sure that Microsoft's licence agreement for Win2000 workstation will prevent you from having 100,000 connections.
Michael
|
|
|
|
|
to 1) If you want a server with thousands of connections, are they from short or longer duration? If its short, you may want (pret)hreaded server model. If it's long and sockets need to communicate with each other, you may want a asychronous server model. AFAIK berkely sockets (or your OS) can not handle 100.000 sockets simoultaneus, you might need some traffic balancing/multiplexing.
to 4) are you planing a central P2P filesharing system (Napster, eDonkey) or do you target on a decentral network (Fasttrack, Gnutella)?
tp 5) I didn't understand the question. Each connected client uses a socket on the server side (usually mapped to a high port).
|
|
|
|
|
TCP can only handle 65,535 ports, of which more than 1024 are reserved. So your 100,000 is a bit screwed from the off.
bakhtawar wrote:
5) Client should know the server address and a well known port to get connect. Now for server only one port will be monitoring the incoming requests for connections. Now is it a good idea that each thread of thread pool create its own port ???
Lets not confuse threads and sockets here. When you have a socket listening on a known port, if something connects to that port, and you accept the conn, you create a new socket which has a different local port.
Also, (I may be wrong), but I think trying to have 100,000 threads would be a sure way to completely kill a windows machine.
jon
STL is a religeon. Enquiries to Reverend Christian Grauss
|
|
|
|
|
I have created a new stream, which looks like this:
template <class charT, class traits>
class basic_osLogFile : public std::basic_streambuf<charT, traits>
{
...
}
What I want to do is create a class that encapsulates this, so I can easily go:
osLogFile f("c:\\Errors");
f << "error number " << nError << endl;
f.close();
I've tried this:
class osLogFile : public std::ostream
{
public:
osLogFile() : ostream(&msb),ios(0) {}
virtual ~osLogFile() { msb.pubsync(); }
private:
basic_osLogFile<char, std::char_traits<char> > msb;
};
but the errors are:
c:\my code\iostreams\testapp\debugstr\\debugstream.h(68) : error C2512: 'basic_ostream<char,struct std::char_traits<char> >' : no appropriate default constructor available
c:\my code\iostreams\testapp\debugstr\\debugstream.h(68) : error C2614: 'osLogFile' : illegal member initialization: 'ios' is not a base or member
c:\my code\iostreams\testapp\debugstr\\debugstream.h(68) : error C2614: 'osLogFile' : illegal member initialization: 'ostream' is not a base or member
Does anyone have any suggestions ?
Thanks.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
<i>And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned.</i> - <b>Christopher Duncan - 18/04/2002</b>
|
|
|
|
|
Hi CG,
This compiles fine on my PC:
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248d
using namespace std;
template<class charT, class T = char_traits<charT> ᡊe9ac73-238b-46be-991d-0f050c37248dclass basic_osLogFile : public std::basic_streambuf<charT, Tᡊe9ac73-238b-46be-991d-0f050c37248d{
};
void main()
{
basic_osLogFile<char> t;
}
Maxwell Chen
Lets make bugs better!
|
|
|
|
|
*just rewording this so it does not sound rude* While that works, if you try operator <<, you'll find it is undefined, the stream object is useless.
I need to derived my stream from basic_streambuf, but to create an instance of it, I need to derive from ostream. I can do this:
basic_osLogFile<char> t;
ostream s(t);
but I'd prefer something a little less ugly, which means creating an ostream that can be instantiated as easily as ofstream, but which uses my streambuf.
Do you have any ideas ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian Graus wrote:
*just rewording this so it does not sound rude* While that works, if you try operator <<, you'll find it is undefined, the stream object is useless.
That's OK, I like step-by-step!
I don't know the details about stream and the hierarchy (haven't pay time to read it), I tried to read your msgs again, this compiles fine:
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248d#include <fstreamᡊe9ac73-238b-46be-991d-0f050c37248d
using namespace std;
template<class charT, class T = char_traits<charT> ᡊe9ac73-238b-46be-991d-0f050c37248dclass basic_osLogFile : public std::basic_streambuf<charT, Tᡊe9ac73-238b-46be-991d-0f050c37248d{
};
class osLogFile : public std::ostream
{
public:
osLogFile() : ostream(&msb),ios(0) {}
virtual ~osLogFile() { msb.pubsync(); }
private:
basic_osLogFile<char> msb;
};
void main()
{
osLogFile s;
s << "Hello";
}
Maxwell Chen
Lets make bugs better!
|
|
|
|
|
You're right - but it only works if I use 'using namespace std' ( which I never do ).
I think if I use std within my own namespace, that might solve my problem somewhat....
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Try this:
class osLogFile : public std::ostream
{
typedef std::ostream ostream;
typedef std::ios ios;
public:
osLogFile() : ostream(&msb),ios(0) {}
...
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I did, I get this:
c:\my code\iostreams\testapp\debugstr\\debugstream.h(83) : error C2629: unexpected 'class osLogFile ('
c:\my code\iostreams\testapp\debugstr\\debugstream.h(83) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
I've made no other changes. replacing the two new lines with a global using namespace std will compile just fine. Obviously I would never do that, but I'm toying with doing it within a namespace I define, and then using mynamespace::osLogFile. would koenig lookup mean that this would pull all of std into the global namespace ?
Obviously if we can get your initial suggestion to work, then that won't matter either way.
Thanks for the help.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Hmmm... this little pesky compiler isn't behaving, I guess. My suggestion comes from a very similar problem I had in the past. My final solution was like this:
namespace sockiostr{
class socketstream: public std::iostream, noncopyable
{
private:
typedef std::iostream super;
public:
socketstream():
super(&sockbuf),
sockbuf()
{}
... and it indeed works.
PS. Of course, in your case the compliant syntax would be
class osLogFile : public std::ostream
{
public:
osLogFile() : std::ostream(&msb),std::ios(0) {}
... but this won't work in VC++ 5.0 --have you given it a try in VC++ 6.0?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
noncopyable ? Is that another base ?
Anyhow, it accepts the typedef syntax IF I use namespace std as well, but without using namespace std, it blows up. I guess I'll put it in a namespace and experiment to see if namespace std remains in place when I use it.
Thanks for the help though.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
noncopyable ? Is that another base ?
Yes it is. I copied and pasted from the original source without any modification. I guess the purpose of this base class is obvious, anyway.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Off-topic, your explicit construction ios(0) clashes with (and takes precedence over) ostream(&msb) . I guess you should omit it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the tip. I'm still pretty new at this... Actually I'm writing this to prove to some people at work that doing it with iostreams will be better than using C style string handling, so any tips that make it 'right' are very much appreciated.
Thanks again
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Does anyone know of any articles regarding the creation of a compiled component that I can call from regular ASP through this method:
dim obj
Set obj = Server.CreateObject("...")
obj.CreateGraphics(...)
set obj = nothing
I would like to write a graphics function that I will be able to call within ASP. Any help would be great. Thanks in advance.
Nick Parker
|
|
|
|
|