|
|
I don't understand why it is said to be asynchronous.
the function CAsyncSocket::Send returns the amounts of bytes sent. this means that we should wait until the function returns.
On the other hand, CAsyncSocket::OnSend is called by Windows when data sending completes.
I don't know what is the benefit of OnSend, when we should wait until Send returns.
Can you explain?
|
|
|
|
|
The "Async" differentiates it from the CSocket class which wraps much less of the sockets
API. CAsyncSocket includes the WSAAsyncSelect functionality by default which is probably where
the "Async" comes from.
To communicate with sockets asynchronously you can use a blocking/non-blocking socket on a
separate thread or use overlapped I/O.
CAsyncSocket::Send(), as well as most of the MFC socket wrapper classes, is just a thin wrapper
for the equivelant socket API. In fact, CAsyncSocket::Send() calls send() and that's it.
Therefore, it's essential to understand Windows Sockets (2)...The MFC wrapper classes don't
provide much beyond a class wrapper for a socket handle (CSocket adds CArchive serialization
support).
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
The Send() method will return immediately, that's because it will only copy the application data into the socket's send buffer but it will not actually wait until the data was transferred or acknowledged from the other peer. As a consequence of this, just sending something does not tell you reliably that the data was completely received or even that the connection is still open. For more details see Jon Snader's Effective TCP/IP Programming (Tip15).
On the other side OnSend() is an asynchronous notification that there is more space in the buffer, the application may now call Send() with more data.
Hope it helps.
|
|
|
|
|
long **iLut3Ddata;
iLut3Ddata =new long *[27];
for(i =0; i<=27;i++)
{
iLut3Ddata[i] = new long[10];
}
for(i=0;i<ldatasize;i++){
for(iodd="9,iEven=8;iOdd">0&&iEven>-1;iOdd-=2,iEven-=2,ii++){
LutData3D[ii] = (unsigned char)iLut3Ddata[i][iEven]; //& iLut3Ddata[i][iOdd];
LutData3D[ii] = LutData3D[ii]<<4|(unsigned char)iLut3Ddata[i][iOdd];
}
for(int ix=0;ix
|
|
|
|
|
icemelt(newbie) wrote: iLut3Ddata =new long *[27];
for(i =0; i<=27;i++)
Immediate problem I'm seeing here is,
it should be,
iLut3Ddata =new long *[27];
for(i =0; i<27;i++)
{
iLut3Ddata[i] = new long[10];
}
In C++ there are 0 based array index.
Here you are writing out of bounds of allocated memory. Hence , it is causing problem , while deleting memory.
|
|
|
|
|
for(int ix=0;ix<ldatasize;ix++){
delete="" []="" ilut3ddata[ix];
="" }
="" <b="">iLut3Ddata=NULL;
delete [] iLut3Ddata;
still the same error occurs but when i add NULL on the array
it doesnt generate error anymore but it detected memory leaks
thanks
|
|
|
|
|
Can you check the Ignore HTML tags... checkbox so we can read your code?
icemelt(newbie) wrote: but it detected memory leaks
Assuming you've corrected the for() statement as shown in Prasad_som's example...
You're allocating 27 blocks of memory on the heap. Are you deleting them ever?
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
You code is not readable at all,
From your original post, I'm guessing your code, how its should look like,
long **iLut3Ddata ;
iLut3Ddata =new long *[27];
for(i =0; i< 27;i++)
{
iLut3Ddata[i] = new long[10];
}
for(int ix = 0; ix < 27 ; ix++)
{
delete [] iLut3Ddata[ix] ;
iLut3Ddata[ix] = NULL ;
}
delete [] iLut3Ddata;
iLut3Ddata = NULL;
|
|
|
|
|
thanks for the code im really still an infant to c++
I was a visual basic programmer back then,
anyways thanks,
|
|
|
|
|
icemelt(newbie) wrote: I was a visual basic programmer back then
I understood it, when you used index up to number of elements in array.
|
|
|
|
|
I need to audit an exe file to ensure that only Administrators have write access. Non-Administrators can have execute access. This is a read-only audit; I will not alter the existing security of a file.
I have tried to search the MSDN and the CodeProject articles. If someone knows what keywords would work for finding answers then that might be all I need.
I don't need a complete sample; just a general direction I hope is enough.
I know about DACLs and SIDs and authorities and RIDs and ACLs and ACEs. I suspect that I need to use the AccessCheck function, but it is certainly complicated. If someone can verify that AccessCheck will do what I need to do then that will help.
|
|
|
|
|
Hello,
i have a dialog based application.
in this dialog i startet a modeless-child-dialog with createdialog.
the child dialog has the properties border = none and style = child.
if the child dialog is closed, i want to call the parent dialog. i can call public functions of the parent dialog, but if i try to change some public variables (i.e. the menu) of the parent dialog, i get an access violation. how cann i invoke the parent, that the child dialog is closed???
if i try to make a modal dialog of the child dialog, then the app freezes.
thanks
-- modified at 18:14 Friday 9th March, 2007
|
|
|
|
|
Can you show your code that it has problem
|
|
|
|
|
Hello,
i found my fault. I simply give the child-dialog a reference to the parent dialog (constructor) and then i can call methods of the parent without getting an access violation.
thanks anyway.
|
|
|
|
|
All I can think of off hand is:
1) Make sure both places refer to the SAME variable. For example, I occasionally make the mistake
of copy/pasting a member variable declaration with its type into code somewhere so it ends up
being a local variable where I copied it, instead of referring to the member variable
2) It's possible to overwrite an array (string, etc.) member that is positioned before the bool
member variable. There's no exception because it's still in valid memory but it trashes the bool.
I've done that one before too .
It may be helpful to put a variable-changed breakpoint on the bool variable. Then your program
will break when the bool is changed and you can look at the stack trace to see who the culprit is.
Mark
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
Hello Mark,
I'm sure that the variable is the same, so I'll check the second scenario, who knows...
Thank you for your feedback!
|
|
|
|
|
Sort of newbie question here. I've read in places that you should avoid returning large class objects (particulary the class String) or datastructures, and instead should call a function and send it back by reference. Like this (ExpressionData is a structure with 3 cstrings):
void CRatiosNewSearchStringDialog::GetExpressionData(SearchExpressionType & Expression)
{
Expression = ExpressionData;
}
as opposed to:
SearchExpressionType CRatiosNewSearchStringDialog::GetExpressionData()
{
return ExpressionData;
}
Where should I draw the line between a large and small piece of data i.e should I bother with all this for a single CString? When should I use return and when should I sent it back by reference? Advice?
|
|
|
|
|
I'm porting some code from gcc to VC++, and a macro I've used for years on gcc is giving me grief on VC++ (Visual Studio 2003).
#define swap16(x) \
({ \
unsigned __int16 __x = (x); \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(__x) & (unsigned __int16)0xff00) >> 8) )); \
})
int _tmain(int argc, _TCHAR* argv[])
{
printf("%d\n", swap16(1);
return 0;
}
This code snippet generates several syntax errors. Any suggestions on resolving this issue are most welcome.
-Josh
|
|
|
|
|
joswr1ght wrote: Any suggestions on resolving this issue are most welcome.
Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
led mike
|
|
|
|
|
led mike wrote: Haven't used it for years but there used to be a compiler switch that produced files containing the expanded code.
Are you referring to the /P option? It writes the preprocessor output to a .i file.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Are you referring to the /P option? It writes the preprocessor output to a .i file.
If it works I am, if not you are.
led mike
|
|
|
|
|
Hmmm....why not just do this...
#define swap16(x) \
((unsigned __int16)( \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0x00ff) << 8) | \
(unsigned __int16)(((unsigned __int16)(x) & (unsigned __int16)0xff00) >> 8) ))
"Great job, team. Head back to base for debriefing and cocktails."
(Spottswoode "Team America")
|
|
|
|
|
I have a straightforward CPropertySheet with CPropertyPages. I need to reset the contents of page "A", depending on the settings on other pages, which means I need a way to catch when pages "open" and "close"
I can catch when a page "opens" by overriding OnChildActivate but I can't catch when a Page "closes". Any suggestions on a sane way to trap these events?
(Note, I know about OnInitDialog() for "open" or OnOk() for "close". Neither of these methods are guaranteed to be called when just bouncing back and forth between pages by clicking on tabs)
Thanks in advance.
|
|
|
|
|
On the pages themselves, you can override OnSetActive and OnKillActive and do whatever you need to do to the parent PropertySheet or other Property pages.
onwards and upwards...
|
|
|
|