|
If your app uses MFC, you can use the DEBUG_NEW macro, and memory leaks will be outputted to your Output windows in Visual Studio. This even tells you the line of code where the object was "new"ed.
At top of all .cpp files:
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
|
|
|
|
|
What is the difference between CSocket and CAsyncSocket
Accrding to MSDN CSocket is a blocking socket and CAsynSocket is a non blocking socket from it what i understood that for example if u make a call on CSocket Recieve it will not return untill u get the whole data (which is wrong when data is on average > 5 k u have to make multiple recieve call to fetch the whole data)
but in case of CAsyncSocket u will have to loop to get whole data .
but another joke written in MSDN is that one should not make multiple recieve calls in OnRecieve while using CSocket::Recieve cauz CSocket is internally dooing looping to recieve whole data.
but with single call u cannot get the whole data atonce. so result of it's is that CSocket becomes useless after transferring 40 , 50 k data on average.
so can anybody explain this scneriao . what is the best way to recieve data in OnRecieve and what socket should i use CSocket or CAsyncSocket.
Note:i am writing a Video streaming software so server on average sends me data range from 5 to 15 k /sec .what i do in OnRecieve is asfollows
do//i am using CSocket
{
res=Receive(ptr,lLength);//where ptr is buffer of size of incoming data
if(res==SOCKET_ERROR)
{
Close();
break;
}
ptr+=res;
total+=res;
}
while(total<lLength);//lLength is size of incoming data
in this case according to msdn i am making multiple recieve call which is wrong , but the reason for it is that i am not able to recieve whold data with one Recive call .
but the result of this code is that it works for hardly 10 to 12 frames. and i have to reconnect again.
No Worries!
|
|
|
|
|
I would try to stay away from CSocket and CAsyncSocket (I have ran into lots of problems with both).. If you use standard WinSock and stay away from those wrapper classes it would be much easier.
Here is a example of how I might do the loop..
char buff[4096];
int nRec;
while(nRec = recv(client,buff,sizeof(buff),0))
{
if((nRec == SOCKET_ERROR) && (nRec != WSAEWOULDBLOCK))
{
}
else
{
}
}
Hope this helps..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
But is it possible to get OnReceive , OnClose like event notifications using WINSOK , can u refer me some good code regarding this.
No Worries!
|
|
|
|
|
Yep you can get all those notifications.. Look around in CodeProject under Internet & Network there are quite a few articles from basic to advanced.. I will dig through my favorites when I get into work and email you some URL's with examples and good reading..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Here is another good WinSock site.. I thought I had more links at work but I don't.. Anyway between Codeproject's Internet & Network area and the following link you shouldn't have many problems converting over to WS..
http://www.sockets.com/
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
thanx for ure reply.Some One has told me that BSD sockets are best of all , what u think abt it.cauz i now that CAsyncSocket is also a wrapper on WINSOCK , if that has problem how can i write a better wrapper than that , specially when u have limited time.
No Worries!
|
|
|
|
|
Strangely enough, I never found any problem with CSocket. [Edit] I was able to send/receive data over 4 mega bytes using CSocket. [/Edit] But I don't have a simple sample program for you.
If you don't mind reusing existing code, maybe you can check out this article[^], which does a lot more than you need.
[Edit] You will have to use it in both of your programs (client and server) [/Edit]
My articles and software tools
|
|
|
|
|
Hi all,
Is it possible to determine how many and what types of hooks are installed?.
Thanks in advance,
Abhishek
|
|
|
|
|
Hello,
I'm currently writing a win32 application and I was wondering how I could make an address bar, like Internet Explorer, for the top of my program? Thanks, Caleb
|
|
|
|
|
You can use a ComboBox for the adressbar and insert the adress with m_myCbo.Addstring() . If you want to show the adresses which are inserted before and you run the programm again write it into the registry or in an *.ini-file with WriteProfileString and GetProfileString() .
Example:
<br />
CString strSection = "My Section";<br />
CString strStringItem = "My String Item";<br />
CString strIntItem = "My Int Item";<br />
<br />
CWinApp* pApp = AfxGetApp();<br />
<br />
pApp->WriteProfileString(strSection, strStringItem, "test");<br />
<br />
CString strValue;<br />
strValue = pApp->GetProfileString(strSection, strStringItem);<br />
ASSERT(strValue == "test");<br />
<br />
pApp->WriteProfileInt(strSection, strIntItem, 1234);<br />
int nValue;<br />
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);<br />
ASSERT(nValue == 1234);<br />
The ini-file got the name of your programm and you can find it under C:\Windows\ or C:\Winnt\.
PR
|
|
|
|
|
1. Create the address bar like dialog window in Resource editor. Set the style CHILD and border NONE.
2. In CMainFrame class declaration add:
CDialogBar m_wndAddressBar;
CReBar m_wndReBar;
3. In CMainFrame::OnCreate() add:
m_wndAddressBar.Create(this, IDD_ADDRESSBAR, CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR);
m_wndReBar.Create(this);
m_wndReBar.AddBar(&m_wndAddressBar);
The IDD_ADDRESSBAR is the resource ID of your address bar in Resource editor.
Robert-Antonio
|
|
|
|
|
|
Hello all
Is there any function to findout the version information of a DLL programatically. Pls help..
Thanks
Hari.
|
|
|
|
|
|
There sure is. The function is defined in <shlwapi.h> which is part of the Platform SDK.
<code>
HRESULT CALLBACK DllGetVersion(DLLVERSIONINFO *pdvi);
</code>
Hope this helps.
|
|
|
|
|
Thank you very much for the replies.
|
|
|
|
|
This is not an API routine, it is a routine that must be implemented by the DLL.
MSDN:
This function is not an API. It is exported by name from each DLL that implements it. Currently, most of the Windows Shell and common controls DLLs implement DllGetVersion. These include, but are not limited to, Shell32.dll, Comctl32.dll, Shdocvw.dll, and Shlwapi.dll.
It will not work on all DLLs.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi
Anyone have a example of SendKey. Peter and I are working on my project and I need some help. I want to sendkey to a window I have a handle for. Thanks to Peter I have enumed all the top level windows, now I need help with SendKey. Will this project ever end?
Best Wishes,
ez_way
|
|
|
|
|
It depends on what kind of keys you want to send... This is just a sample:
// suppose your window handle is hwnd, you want to send key "A" to it.
::PostMessage(hwnd, WM_CHAR, WPARAM('A'), LPARAM(0));
|
|
|
|
|
Thank you, very helpful!
I am sending
::PostMessage(hwnd, WM_CHAR, WPARAM('^'), LPARAM(M));
Ctrl+M
Best Wishes very good~!
Best Wishes,
ez_way
|
|
|
|
|
Is there an easy way to display incoming video(like from a camcorder)on a computer using visual C++ or visual basic?
Thank you
|
|
|
|
|
|
Well the DirectShow API of the DirectX 8 and up are surprisingly not that challenging to learn. The documentation provided with the SDK will have you displaying all kinds of streams in no time. Personally I developed a VERY basic TV Viewing application in 2 days from scratch (I knew nothing about DirectShow before)
|
|
|
|
|
If you ever download the VS6 samples, about 100megs from msdn, it has a lot of cool things... including wordpad yes the 95 version although there is no difference, lol with the new and old one (95 and xp)... to find this, open the c++ documentation go to mfc samples, go to mfc ole samples and out of the list should be displayed wordpad, yes with all the source code, you can compile it, alter it... unless windows made it so if it is changed it will report you, jk . neat little things can be found by looking at and remembering old stuff.
Actual Linux Penguins were harmed in the creation of this message.
|
|
|
|