|
In my experience, as far as client side is concerned, CSocket/ASyncSocket should never cause any trouble. Though i personally prefer CAsyncSocket over CSocket , to avoid blocking issues. As such CAsyncSocket requires special care[^].
If we talk about server side, it depends upon the scalability desired (i.e the maximum number of users you want to simultaneously connect) and throughput (Data flow rate into and out of server). If both the attributes are low CAysncSocket should work fine. Otherwise you may need to dig into WinSock API and I/O completion ports.
|
|
|
|
|
first of all i want to brief u about my project.
It is a Video streaming software , so almost 5 tp 20 k data is sent across sockets per sec.For this i am using sockets with CSocketFile and CArchive attatched to CSocket object that is why i cant use CAsyncSocket .
what happens that after on average 10 to 15 frames , data socket becomes usless in a sense that even server sends me data but on client side OnRecieve does not calls . and on server end Send does not returns any error code.so what happens in this condition i close socket and reconnect with server , although i do it transparent from user , but surely a kinda delay comes.
So now my question is it due to CSocket , blocking nature (although i can use CAsynSocket cauz i am doing synchronize communication) but due to CSocketFile and CArchive i am using it.
No Worries!
|
|
|
|
|
Hi, Im using the FindWindow() function to find an application called Fullscreen.exe and then sending a WM_CLOSE call to it. However I get this error:
nPOSDlg.cpp(367) : error C2440: '=' : cannot convert from 'class CWnd *' to 'struct HWND__ *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
nPOSDlg.cpp(374) : error C2660: 'SendMessageA' : function does not take 4 parameters
This is the code that I have put into my OnAppExit(); because I want it to kill Fullscreen.exe when nPOSdlg closes.
HWND hWnd;<br />
hWnd = FindWindow(NULL, TEXT("Fullscreen"));<br />
if(hWnd == NULL)<br />
{<br />
}<br />
else<br />
{<br />
SendMessage(hWnd, WM_CLOSE, 0, 0);<br />
}
How do I convert from CWnd to HWND or what do I need to do?
Please help, thanks!
Ashman
|
|
|
|
|
to keep things simple, just add :: before the FindWindow function, this will let you expelicitly use the HWND version.
|
|
|
|
|
Hi.
Can i know the return value of ReadFile when a timeout occurs, if the commtimeout structure was previously set?
I am writing a simple program that reads the serial port for characters arriving. Anyone can recommend a better option than the one i use?
Target device is WindowCE, using embedded Visual C++ 3.0
bool WaitForChar(unsigned char character,DWORD dwTimeout)
{
DWORD dwTimeStart,dwRead;
BYTE in[2];
dwTimeStart = GetTickCount();
while((GetTickCount() - dwTimeStart) < dwTimeout)
{
if(ReadFile(hPort,in,1,&dwRead,NULL))
{
if(dwRead != 0)
{
if(in == character)
return TRUE;
}
}
else
return FALSE;
}
return FALSE;
}
|
|
|
|
|
Hi...
What's the command to close a parent property sheet so that it's child pages are closed automatically also?
Thank you.
|
|
|
|
|
EndDialog() perhaps.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
plz give me example how to create web server with PHP and ASP page enabled.
donald
|
|
|
|
|
can you give example about implementing webserver using cgi
platform:windows2000
i've already try passing query_string using environment variable. i try it on command prompt. i use "set" command then query_string and variable name and its content.
then using syntax c:\php\php [php file where i wrote the script to display a $name variable] <[file location where i wantto redirect].
but i cannot do the same thing when i try to passing form data (POST method).
i've used command line winCGI-exe cgi-data-file. winCGI-exe is the complete file path to CGI prog exe like c:\php\php.exe
i've also completing cgi-data-file content.
it's consist of some sections like [CGI] section, [Form External] section,etc.
in [CGI] section i've wrote all the keywords like Request Protocol,Executable Path,etc. But again, it doesn't work. until once i met a line "input file not spesified" in command line of DOS after some http header,...PLZ help me!!!
NOTES: i found all the CGI specification on website with "Windows CGI Interface" keyword.
one of the author is Ken.Coar@Golux.Com and rdenny@dc3.com
donald
|
|
|
|
|
I wrote an VC++ v6 MFC app that works fine when linked with the "Debug" version of MFC. However when I compile in the "Release" mode, the app crashes. I think I narrowed the problem to a worker thread posting a message to a window thread (by calling PostMessage()). I recreated the problem in a small MFC project, parts of which are listed below (I can also provide the project files if anyone is interested). In the debug version of the program, the worker thread continually sends an WM_APP message with one parameter to a CDialog-based window which displays the running counter. In the Release version, the counter stops at "2" then crashes. I'm running on XP Pro, but I also had the problem in Win98.
I'm stumped
reymano
<br />
<br />
#include "stdafx.h"<br />
#include "testMFC.h"<br />
#include "testMFCDlg.h"<br />
<br />
<br />
<br />
CTestMFCApp theApp;<br />
CTestMFCDlg *dlg;<br />
<br />
bool goFlg;<br />
<br />
UINT threadProc( LPVOID pParam )<br />
{<br />
int i=1;<br />
goFlg = true;<br />
while(goFlg)<br />
{<br />
Sleep(2000);<br />
PostMessage(dlg->m_hWnd,WM_APP,i,0);<br />
i++;<br />
}<br />
<br />
return 0;<br />
}<br />
<br />
<br />
BOOL CTestMFCApp::InitInstance()<br />
{<br />
<br />
<br />
#ifdef _AFXDLL<br />
Enable3dControls();
#else<br />
Enable3dControlsStatic();
#endif<br />
<br />
dlg= new CTestMFCDlg();<br />
<br />
<br />
m_pMainWnd = dlg;<br />
dlg->CreateWnd();<br />
dlg->ShowWindow(SW_SHOW);<br />
<br />
AfxBeginThread(threadProc, NULL,<br />
THREAD_PRIORITY_HIGHEST,0,0,NULL);<br />
<br />
return TRUE;<br />
}<br />
<br />
<br />
<br />
<br />
#if !defined(AFX_TESTMFCDLG_H__)<br />
#define AFX_TESTMFCDLG_H__<br />
<br />
<br />
class CTestMFCDlg : public CDialog<br />
{<br />
public:<br />
CTestMFCDlg(CWnd* pParent = NULL);
CreateWnd();<br />
<br />
enum { IDD = IDD_TESTMFC_DIALOG };<br />
CString m_Text;<br />
<br />
protected:<br />
virtual void DoDataExchange(CDataExchange* pDX);
<br />
protected:<br />
HICON m_hIcon;<br />
<br />
virtual BOOL OnInitDialog();<br />
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);<br />
afx_msg void OnPaint();<br />
afx_msg HCURSOR OnQueryDragIcon();<br />
afx_msg void OnClose();<br />
afx_msg void OnUser(WPARAM);<br />
virtual void OnOK();<br />
virtual void OnCancel();<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
#endif <br />
<br />
<br />
<br />
#include "stdafx.h"<br />
#include "testMFC.h"<br />
#include "testMFCDlg.h"<br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#undef THIS_FILE<br />
static char THIS_FILE[] = __FILE__;<br />
#endif<br />
<br />
extern bool goFlg;<br />
<br />
<br />
CTestMFCDlg::CTestMFCDlg(CWnd* pParent )<br />
: CDialog(CTestMFCDlg::IDD, pParent)<br />
{<br />
m_Text = _T("");<br />
}<br />
<br />
CTestMFCDlg::CreateWnd()<br />
{<br />
Create(IDD, NULL);<br />
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);<br />
}<br />
<br />
<br />
void CTestMFCDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
CDialog::DoDataExchange(pDX);<br />
DDX_Text(pDX, DLG_TEXT, m_Text);<br />
}<br />
<br />
BEGIN_MESSAGE_MAP(CTestMFCDlg, CDialog)<br />
ON_WM_SYSCOMMAND()<br />
ON_WM_PAINT()<br />
ON_WM_QUERYDRAGICON()<br />
ON_WM_CLOSE()<br />
ON_MESSAGE(WM_APP, OnUser)<br />
END_MESSAGE_MAP()<br />
<br />
<br />
<br />
void CTestMFCDlg::OnUser(WPARAM p) <br />
{<br />
m_Text.Format("Testing %d",p);<br />
UpdateData(false);<br />
}<br />
|
|
|
|
|
The prototype for OnUser() is wrong, and you're ending up with a corrupted stack. It must be
LRESULT CTestMFCDlg::OnUser ( WPARAM wParam, LPARAM lParam ); See the docs for ON_MESSAGE for more details.
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0.1! | RightClick-Encrypt
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
That did it. Thanks Mike.
I wish the debug version of MFC was less forgiving so I could have found it sooner.
reymano
|
|
|
|
|
Hey
I need to know how to display the system date and time in a static control in format: Day, Date, Time, AM/PM. Can someone please help me, this is a fundamental aspect to my program.
Thankyou
Ashman
|
|
|
|
|
have a look at strtime and strdate and related functions to create a formated string of a time and a date.
and to put it on the dialog, create a CStatic and use SetWindowText .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
you can do this like that :
CTime t1;
t1=CTime::GetCurrentTime();
((CStatic*)GetDlgItem(YOUR_STATIC_ID))->SetWindowText((LPCTSTR)t1.Format("%H:%M:%S"));
that would be running...
TOXCCT
|
|
|
|
|
My program stops and gives me the following error:
Loaded 'C:\WINNT\system32\KERNEL32.DLL', Cannot find or open a required DBG file.
Please help.
Thanks,
Jessica
|
|
|
|
|
on what case does it freeze?
please explain a bit more please...
TOXCCT
|
|
|
|
|
It seems to be shutting down every time a calculation is being made. Any suggestions?
Here is the program. Maybe I just coded something wrong...I dunno. Thanks for the help though.
//Write a program that computes the weekly pay of managers, hourly
//employee's, commission employee's and piece workers.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int main()
{
int payroll;
float manager, hourly, commission, piecew;
double numhours, pieces;
cout<< "Enter a payroll code from below: \n";
cout<<"\n 1 for Managers: ";
cout<<"\n 2 for Hourly Employees: ";
cout<<"\n 3 for Commission Employees: ";
cout<<"\n 4 for Piece Workers: ";
cin>>payroll;
switch (payroll)
{
case 1:
cout<<"\nEnter the fixed weekly salary for managers: ";
cin>>manager;
cout<<"\nThe weekly salary for your managers is: "<<manager<<endl;
break;
case 2:
cout<<"\nenter="" the="" fixed="" hourly="" wage:="" ";
cin="">>hourly;
cout<<"\nEnter the number of hours worked: ";
cin>>numhours;
if (numhours<=40)
{
cout<<"\nThe weekly wage for your hourly employee's is: ";
cout<<(hourly*40)<<endl;
}
else
{
cout<<"\nthe weekly="" wage="" for="" your="" hourly="" employee's="" is:="" ";
cout<<((hourly*40)+((numhours-40)*(1.5*hourly)))<<endl;
}
break;
case="" 3:
{
cout<<"\nenter="" the="" gross="" sales="" commission="" employee's:="" ";
cin="">>commission;
cout<<"\nThe weekly wage for your commission employee's is: ";
cout<<(250+(0.057*commission))<<endl;
}
break;
case 4:
{
cout<<"\nenter="" the="" fixed="" salary="" per="" piece="" produced:="" ";
cin="">>piecew;
cout<<"\nEnter the amount of pieces produced by the worker: ";
cin>>pieces;
cout<<"\nThe weekly wage for your piece workers is: ";
cout<<(piecew*pieces)<
|
|
|
|
|
i'm confuse, but i don't have the courage to analyse your whole surce code. could you please help telling me where it freezes (line number if you know, debug infos if any...)
i'll do my best, i you don't know, but i don't promise anything
TOXCCT
|
|
|
|
|
Anybody have any idea how to solve Brouncker's continued fraction expansion using a recursive function???
ie: 4/pie = 1 + 1^2/(2+ (3^2/2+ (5^2/2+....))).
Thanks.;P
a_hyams
|
|
|
|
|
Smells like homework... what have you done so far?
Also, it's 'pi', not 'pie'
- Mike
|
|
|
|
|
Hello,
I have created an MFC SDI and I want to set the main windows title. At the moment I have:
this->SetTitle("My Name");
But I'm left with a "Untitled" after the title:
My Name - Untitled
How do I get rid of "Untitled" from the title?
Thanks in advance;)
|
|
|
|
|
|
Thank you
|
|
|
|
|
Hi,
I updated from Intellipoint 4.1 to 5.0 but since i don't have the Explore My Computer option for a mouse button assignment i decided to buid my own using the WindowsHookEx and the WH_GETMESSAGE or the WH_MOUSE_LL type for the WM_XBUTTONDOWN and MK_XBUTTON1 to open windows explorer sending the WM_HOTKEY to the Shelltraywindow and it works except for some kind of windows when it opens twice and process message (Back button). Windows like the ones in VS.net tabbed environment, inside a popup menu, some toolbars.
Any ideas will help a lot.
Thanks.
NMiceli
|
|
|
|