|
Caslen wrote: appears to be corrupted or somehow has missing data
How do you know that? Are you getting an error message?
|
|
|
|
|
Yeah I perhaps should have mentioned that when I try to open the resources for the project in the resource view I get a "Guideline must specify type" message whatever that means. Also I have an older version of the file which has lines missing that I am pretty sure aren't due to any of my edits
|
|
|
|
|
I am writing a multithreaded TCP Server Application(MFC).
I have written simple TCP server earlier n it worked fine. The tutorial I used told that for
multithreaded server I have to use more than one Socket variable and It also told that the server
should spin individual thread for every client.
But I think I am writing wrong code.
Where am I going wrong? any suggestions please.
My Code looks like this:-
class CsockDlg : public CDialog
{
public:
CsockDlg(CWnd* pParent = NULL);
.
.
.
private:
CMySocket m_sListenSocket;
CMySocket m_sConnectSocket;
public:
void OnAccept(void);
void OnConnect(void);
void OnClose(void);
void OnReceive(void);
void OnSend(void);
static UINT ThreadServer(LPVOID pParam);
void TS(void);
};
BOOL CsockDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
.
.
.
int m_iPort = 4000;
m_sListenSocket.Create(m_iPort);
m_sListenSocket.Listen();
return TRUE;
}
void CsockDlg::OnAccept(void)
{
AfxBeginThread(ThreadServer, this);
}
UINT CsockDlg::ThreadServer(LPVOID pParam)
{
CsockDlg* O = (CsockDlg*)pParam;
CMySocket c;
O->m_sListenSocket.Accept(c);
return 0;
}
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Question: Where did you get that example from?
There are plenty of examples out there that can help setting up a working networking application (with or without multi threading). For some examples using sockets see Winsock FAQ[^].
/M
Future lies in the future.
|
|
|
|
|
Tutorial was only for Simple TCP server.
This is my experimental code.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Please have a look at the link I posted, perhaps you can find something that fits your needs. If you want to write a GUI application with networking it could be worth to have a look at event-based examples (e.g. using MFC's CAsyncSocket ) it saves you the hassle of using threads and locks.
Btw, there are other socket libraries than MFC out there:
* Alhem
* Boost
* SharkEngine
* QT
* and many others
Hope it helps!
The past lies in the future
|
|
|
|
|
Calculate factorial of any number less than 10000,but I don't know how to start with? I just want to get an idea, not the source code.
|
|
|
|
|
forPower wrote: Calculate factorial of any number less than 10000
That's a big number to find the factorial of! You won't be able to do it with the existing datatypes, and normal arithmetic techniques. But you could use something like the BigNum[^] library. It is an excellent library and has been around for a while.
FYI, I just calculated the factorial of 10000 online (using BigNum) and the answer is: here[^]
forPower wrote: I just want to get an idea, not the source code.
FYI, BigNum is free of cost and open source (LGPL).
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Start making space for a lot of digits...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
forPower wrote: Calculate factorial of any number less than 10000,but I don't know how to start with?
Start with 1!.
With standard C , using an (or two three... ) array of (circa) 40000 unsigned char s you may roll you own-hand-crafted computation, anyway I doubt the output will be produced in 1 ms...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, October 16, 2009 5:16 AM
|
|
|
|
|
Can you calculate factorials on paper? Until you get that much squared away, trying to write code is just going to get in your way.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
0- do you know what a factorial is ?
0.5- did you google/bing about that ?
1- do you know how to calculate factorial on paper ?
2- can you translate that into code ?
2.5- did you even try something ?
anyway, don't use recursion.
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: 2- can you translate that into code ?
2.5- did you even try something ?
Unfortunately I think that in this specific case, just translating the factorial logic into code simply won't work. If we use the datatypes that are available to us, and assuming that we use a 64 bit unsigned integer, the largest number that it can hold would be barely sufficient to hold the value of 20 factorial. For holding the resultant value of the computation of 40 factorial, there are no datatypes offered by the tools and languages used usually (it would be larger than what an 128 bit integer can hold!)
And the OP wants to find the factorial of not 40, but the factorial of *cough* 10000. The way I know of is to use arbitrary precision arithmetic and the OP didn't know it. He just wanted to know how to get started with it.
However, I do agree with you that he could have done a bit of Googling around.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
well, if the OP cannot even code a simple factorial for small numbers, then defining it for large numbers is secondary.
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: well, if the OP cannot even code a simple factorial for small numbers...
That's what I inferred from his post, too.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I want to fill contacts in outlook through programatically i,e by using Mapi can anybody provide me some samples so that iam aware of things..... Thanks in Advance...
|
|
|
|
|
The CP article search engine is wonderful...[^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
It's all described here[^].
|
|
|
|
|
It sounds that MFC auto swiches unicode/ansi lib and dll for main unicode/ansi exe (not sure).
My question:
Is it OK if main exe is unicode but user dll is ansi format?
Should I change user dll to unicode also?
|
|
|
|
|
If you are not passing strings to/from the dll, then there's no reason to change. If you are passing strings, then you must either always convert strings, or change dll to compile with UNICODE.
In general, changing dll to match exe is the better approach. Just add a "Unicode" project in the IDE, so you can choose which to build. Your dll should be named appropriately - e.g., MYDLLA.DLL, MYDLLU.DLL - for the Ansi and Unicode versions.
|
|
|
|
|
In MFC, unicode project is with option (1)_UNICODE and (2)wWinMainCRTStartup.
setting (1) can be used for win32, but (2) can't, because it is for MFC.
If without (2), win32 project is not real unicode - test by ansi string in function MessageBox(0,"ppppp","nnnn",MB_OK); and no compile errors.
What is similar setting of (2)wWinMainCRTStartup for win32 project?
|
|
|
|
|
From MSDN:
Visual C++ supports defining a wmain function
and passing wide-character arguments to your Unicode
application. You declare formal parameters to wmain, using
a format similar to main. You can then pass wide-character
arguments and, optionally, a wide-character environment
pointer to the program. The argv and envp parameters to
wmain are of type wchar_t*. For example:
wmain( int argc, wchar_t *argv[ ], wchar_t *envp[ ] )
|
|
|
|
|
But how to change it from project settings as in MFC?
manually change main to wmain, WinMain to WWinMain, DllMain to WDllMain?
|
|
|
|
|
exe/dll file size alignment is 512 bytes with option /OPT:NOWIN98.
Is 512 bytes minimum size alignment for exe/dll?
I hope change it to smaller, how to do it?
|
|
|
|
|
16 is the minimum size, but IIRC making it smaller than 512 can cause problems. (I also vaguely recall trying 16 on a project and running into a linking issue.)
|
|
|
|