|
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.
|
|
|
|
|
Hello everyone:
I want to transfer a function pointer from a wtl project to a MFC dll.
Do I need to make the function as a callback function?
How to do?
If having some sample code, please email to me .
Thank you.
-Freehawk.
|
|
|
|
|
Hi guys, I do need your suggestions.
In document based MFC application, there is a menu item “ID_FILE_OPEN”. When you press it, it will run cWinApp::OnFileOpen.
Now, I have a dialog based MFC application. I want to add a button to achieve above function. When I press the button, it can open a file explorer or file manager.
By the way, this MFC application doesn’t have StdAfx files.
What I should do?
|
|
|
|