|
Call AfxSocketInit() in each thread that is using sockets.
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"
|
|
|
|
|
I have a class member CSocket variable that is used in several class member functions. AfxSocketInit() is first called in the app's InitInstance() . Should I also call it in my class constructor?
The problem is that the app will receive half of the file sent by a TCP server and then generate the error. The size of the file doesn't make a difference!
|
|
|
|
|
masnu wrote: Should I also call it in my class constructor?
No, you need to call it at the beginning of any thread that uses sockets.
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"
|
|
|
|
|
Hi,
I have been trying to construct a simple server client system just to come to grips with TCP/IP programming. It has a authentication system where the protocol goes something like...
server: "AUTH"
client: "AUTH:<user>:<pass>"
server:"AUTH:SUCCESS" or "AUTH:FAILURE" depending on result
server may follow the "AUTH:FAILURE" with an "EXIT" to break the connection in certain conditions. however when i try to send the "AUTH:FAILURE" and "EXIT" strings in succession, i land up receiving "AUTH:FAILUREEXIT" at the client which then messes up things. I have tried disabling the Nagle's algorithm but the problem still persists.
Any pointers on how i could solve this?one way is to introduce seperators between two send()s but i would like to know of any methods to get by without seperators.
Thanks!
clueso
|
|
|
|
|
Nagle-ing might not have anything to do with it. The Nagle algorithm works to improve the performance of a send operation. But the intermediate network equipment as well as the receving system are free to combine or break apart data as they see fit - TCP sockets are stream sockets, and as such, data will stream into and out of them.
Moving to a datagram socket will prevent this, but you lose the automatic guarnanteed delivery you get with TCP.
I would suggest better parsing (watch for keywords made of combined data segments), change the format of the messages (e.g. each one starts with 0x01 and ends with 0xFF ), or change to a request-ack system, where each command gets an ACK back before the next one is sent.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hi,
I have say N Elements, of N i want R cominations of N.How to find the combinations.So that i can take them in array nd use them..and they should not repeat ..
Thanks before
James
|
|
|
|
|
RockyJames wrote: How to find the combinations.So that i can take them in array nd use them..and they should not repeat ..
if they should not repeat, they are not Combinations but Arrangements.
n!
nCp(n, p) = ---------------
(n - p)! * p!
n!
nAp(n, p) = ----------
(n - p)!
see in my VisualCalc to see a possible implement of them (you can just have a look at the Doxygen Parser documentation provided at the top of the article - when having unzipped it, you will find your answer by looking at doc/html/class_c_v_calc_parser.html#8f5e1a27fee1e8aea82de140cd8fc839 ).
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
-- modified at 13:08 Thursday 16th February, 2006
|
|
|
|
|
I know the formula for cominations and permutations.Say N=6 Elements and p=3
In what cominations should i need to fill my Array Double A[3][10] Each time i have take 3 elements out of 6 elements ..And they dhould not reapeat.
thanks before
James
|
|
|
|
|
toxcct wrote: if they should not repeat, they are not Combinations but Arrangements.
Not quite. Permutations and combinations can both repeat and not repeat. The formulas look very similar.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
i want find out cominations for N=6 and r=3
i.e 1 2 3
2 4 5
3 4 6
2 3 4
3 4 5
4 5 6
5 6 1
5 6 2 ........etc...So i want to implement this..Each time i want these elementd data in to array and perform some task......Can any help me in doing this.....
I hope i am more clear this time....Hope so.....
Thanks befor
James
|
|
|
|
|
See here.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
In previous versions of Visual Studio, the linker an the editbin utility had the ability to convert object files from OMF to COFF format. I can't make it work with the link.exe and editbin.exe versions in VS2005.
Does anybody know if that conversion was intentionally removed in VS2005 or if it's just a bug?
I have a project in which some files are compiled with arity/prolog32 (v.1.1). The output of the prolog compiler is an object file in OMF format. Actually, the compiler itself tries to silently convert it to COFF by calling editbin behind the scenes. But with VS2005 the conversion fails and the object file remains in OMF format. Trying to convert the file by explicitly calling EDITBIN from the command line produces the following output, and the file is not converted:
Microsoft (R) COFF/PE Editor Version 8.00.50727.42<br />
Copyright (C) Microsoft Corporation. All rights reserved.<br />
<br />
prlg_ifce.obj : warning LNK4048: Invalid format file; ignored<br />
<br />
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hi,
I have a COM DLL, and am trying to access this DLL from a MFC application in VC 6.0. But the linker is throwing the following error:
unresolved external symbol "int __stdcall AfxMessageBox
An eg of the usage of AfxMessageBox in the Application code is as under:
AfxMessageBox("Connection Failure",MB_OK);
Help would be quite Helpful !!!
|
|
|
|
|
|
toxcct wrote: remove the 2nd parameter
Am still getting the same linker error...
|
|
|
|
|
Sounds like your COM DLL is not built to use MFC.
Instead of dragging MFC into your COM DLL, I would just use MessageBox(...) instead.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I'm using SQLXMLBulkLoad object to read XML/XSD files and insert data and structure into empty SQL Server database.
SQLXMLBulkLoad::Execute( XMLFile, XSDFile) is executed succesfully, but the database remains empty. No tables are created and no data copied.
SQLXMLBulkLoad.BulkLoad property is TRUE
SQLXMLBulkLoad.SchemaGen property is TRUE
Are there some other properties needed for correct Bulkload, or some SQL Server setting to allow this operation?
thanks.
|
|
|
|
|
I am trying to develop a MFC program with database support using DAO.I am using VC6.0 and access 2003.Yet I got the message that VC6.0 can't detect access 2000 database when using DAO.How can I solve this problem?Thanks!
|
|
|
|
|
Hi dear friends,
I want to add ATL support to MFC DLL,
Can you help me?
|
|
|
|
|
It involves adding a global _Module variable and initializing it properly. If you make a dummy DLL project with the AppWizard, and enable MFC and ATL support, you can see how the ATL part is initialized.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi, Thanks for your reply.
I meant adding ATL support to an MFC extension DLL. You know that in VC++ 6.0 (and also later) you can not add ATL support to MFC extension DLLs but you can add this support to regular DLLs.
Knowing this, can I add ATL support to MFC extension DLLs in the way you mentioned.
|
|
|
|
|
a_kiani wrote: I want to add ATL support to MFC DLL,
Could you tell me which ATL class you intended to use in MFC dll.!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi Dear Friend,
Thanks for your attention.
I want to add simple ATL object to my MFC DLL,
|
|
|
|
|
Hi,
im using this code to copy some data from a ListCtrl
to clipboard.
void CXYZ::copyToClipBoard()
{
CString strTemp="";
POSITION pos = this->GetFirstSelectedItemPosition();
if (pos == NULL)
TRACE("No items were selected!\n");
else
{
while ((pos) && (1))
{
int nItem = this->GetNextSelectedItem(pos);
pEl=Tree.getItem(nItem);
if (pEl->sev == 1)
strTemp+="Summary";
else if (pEl->sev == 2)
strTemp+="Unknown";
}
}
if(0 != OpenClipboard())
{
// clipboard varibale and buffer to hold text
HGLOBAL clipbuffer;
char * buffer;
// empty the clipboard first
EmptyClipboard();
// Allocate enough memory
clipbuffer = GlobalAlloc(GMEM_MOVEABLE, (strTemp.GetLength()+1)*sizeof(TCHAR));
// lock the buffer for entire system
buffer = (char*)GlobalLock(clipbuffer);
// copy the text to buffer
memcpy(buffer, strTemp,strTemp.GetLength()*sizeof(TCHAR));
buffer[strTemp.GetLength()+1] = (TCHAR) 0;
// unlock the buffer for entire system
GlobalUnlock(clipbuffer);
// set the type of the clipboard data
SetClipboardData(CF_TEXT,clipbuffer);
// close the clipboard
CloseClipboard();
}
This is working fine for about 150000 items.
But when i have about 500000 items i see a strange behaviour.
The memory usage is increasing for a short time. After this it drops
back to the value before the copy attemp but the process is stuck
in the while-part of this method.
Are there any limits of a CString i`m not aware of?
Or is there an other way to copy more than 150MB to clipboard?
And as last question what way is the fastes to concatenate many strings?
Are stringstreams better or what other ways are possible?
thx
t2x
|
|
|
|
|
Using CString to cat a large number of string is very slow. Each cat can easily cause a new memory allocation which is bad. stringstream should work just fine unless the allocation system stinks. Even a vector of chars is better since it uses a doubling algorithm.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|