|
ALLERSLIT wrote: Now this works perfectly fine if the webserver is working well, but sometimes it just sits there trying to recv() forever..
Iam not exactly sure what causes it but either way, I need a way to set a timeout or something similiar..
There are multiple choices:
- adjust the send/receive timeouts with setsockopt(), see SO_SNDTIMEO and SO_RCVTIMEO
- use non-blocking/asynchronous sockets, makes event based applications so much easier
- use a C++ networking library/API offering timeouts or search for a HTTP client class, would be my recommendation
Happy coding!
|
|
|
|
|
hello guys...im doing small project in TAPI.
- I show all the available lines in combo box.
- Now when I select a line device from combo box; I get its index and pass it to lineOpen(), but this does't work.
- Finally I hard-coded the line device id (ZERO in this case) which worked absolutely fine.
My question is: why does the combo box method is't working as it should be. What should I do?Any idea? thnx
|
|
|
|
|
overloaded Name wrote: My question is: why does the combo box method is't working as it should be. What should I do?Any idea? thnx
What do you mean with that?
Could you please post the relevant code?
Have you checked the method's return value?
(To sum up: "have you used the debugger?")
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Could you please post the relevant code?
well there is nothing much for the code. I get index and pass it which does't work.
If I hard cord the line device id then it works fine. Here is the code
DWORD index = m_comboDevices.GetCurSel();
OpenLine(index);
WaitForIncomingCall(index);
CaptureEvents();
Everything is fine so the only problem is; selecting the line device from combo box is not working.
|
|
|
|
|
There are two possible problems in the obove code:
1. You do not check that the return value from GetCurSel() is a valid response (i.e. no error checking).
2. Are you sure that the CombBox index value is the same as the line number? What does WaitForIncomingCall() actually do?
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
overloaded Name wrote: DWORD index = m_comboDevices.GetCurSel(); //m_comboDevices = control variable of combo box
OpenLine(index); //a function opens a line with provided argument
WaitForIncomingCall(index); //it waits for incoming calls on the provided line (argument)
CaptureEvents(); //this function captures events.
The correct approach here is:
DWORD index = m_comboDevices.GetCurSel();
if (index == CB_ERR)
{
}
..
Moreover: why don't you use the debugger (or, for instance, the TRACE macro) to inspect index value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello,
I am hoping that someone might know how to execute a user-mode executable from a driver? Either DDK or for mac.
I have found that neither exec(), fork() or system() work in the DDK. What other compilers could these statements work for (windows/mac)?
|
|
|
|
|
I don't think that can be done (nor should be done) directly, as the protection would be insufficient. Maybe the driver could get it scheduled through Windows Scheduler though, I don't really know.
|
|
|
|
|
There is no direct way to do this directly from a driver.
Usually there is a support application or service that runs in user mode and waits on a named event.
The driver then signals this event whenever a process needs to be created.
In the user mode app, the wait is satisfied and it creates the process.
|
|
|
|
|
Why?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
The purpose would to be to run a portal program for all the applications on a storage device.
|
|
|
|
|
What is the best way to connect an database through an worker thread ?
I teach from here[^] how to use an worker thread ...
Ok , but in worker thread I use theApp global member variable which have an database connection ... but the problem is that not every time thread unconnect database or destroy theApp.m_pDB member variable from CMyApp::ExitInstance() event .... I don't know why ?!
So , can you tell me how to connect to an database from an worker thread ? Thank you !
|
|
|
|
|
mesajflaviu wrote: So , can you tell me how to connect to an database from an worker thread ?
I would be inclined to connect to the database in the primary thread, and then pass the CDatabase pointer to the secondary thread.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Connection to database I make in primary thread ... and now , since I discover threads , I try to switch connection to an worker thread ...
Ok , I have connection attach it to global theApp variable ... ex : theApp.ExecuteSQL(...) , theApp.GetData(...) , etc. so , you say to pass this varaible ( theApp ) as parameter to worker thread ? Since theApp is global variable , what is the point ?
|
|
|
|
|
mesajflaviu wrote: so , you say to pass this varaible ( theApp ) as parameter to worker thread
Not what I said at all.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Then , to pass theApp.m_pDB ( CDatabase* kind of ) like parameter to worker thread ?
|
|
|
|
|
Hi,
I'm using a CListCtrl in an MFC app (vs2008) that has group view enabled. All works fine on my Win7 PC but when I run my app on a Win XP system the list will not sort the list items when group view is enabled. Is this a WinXP limitation?
Thanks.
|
|
|
|
|
I have come across a similar situation recently, but on Windows 7 using straight Win32 API; are you sure it sorts correctly within groups? I found a solution here[^], it may help you also.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thanks for the reply, Richard. I will try what the link suggests.
PS
I've just doubled checked and it does indeed sort on groups in Win7.
Thanks
|
|
|
|
|
Hi,
I can't seem to properly create a compatible bitmap in my MFC application. I'm trying to StretchBlt a byte buffer (with 8-bit greyscale pixel information) to a DC, but the only way to get it done is by taking a rather unconventional detour. Here's what I do:
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, "bitmap.bmp", IMAGE_BITMAP,
0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
CBitmap cBmp;
cBmp.Attach(hBmp);
cBmp.SetBitmapBits(m_width*m_height, datap);
CDC dcMem;
dcMem.CreateCompatibleDC(dc);
HBITMAP BitmapOld = (HBITMAP)SelectObject(dcMem, cBmp);
dc->StretchBlt(xOffset, yOffset, m_width*rectSizeX, m_height*rectSizeY, &dcMem, 0, 0, m_width, m_height, SRCCOPY);
dcMem.SelectObject(BitmapOld);
dcMem.DeleteDC();
The file bitmap.bmp contains an uncompressed 8-bit greyscale image with exactly the same dimension of m_width*m_height. So far only by loading this one file first, attaching it to CBitmap cBmp and then calling SetBitmapBits with the pointer to my own byte buffer (datap), thus overwriting the bitmap information from the file, I can create a compatible bitmap out of my byte buffer that I can blit into the window. If I go like this
BITMAPINFO *lpInfo = new BITMAPINFO;
lpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
lpInfo->bmiHeader.biWidth = m_width;
lpInfo->bmiHeader.biHeight = m_height;
lpInfo->bmiHeader.biPlanes = 1;
lpInfo->bmiHeader.biBitCount = 8;
lpInfo->bmiHeader.biCompression = BI_RGB;
lpInfo->bmiHeader.biSizeImage = m_width*m_height;
lpInfo->bmiHeader.biClrUsed = 0;
HBITMAP hBmp = (HBITMAP)::CreateDIBSection(0, lpInfo, DIB_RGB_COLORS, 0, 0, 0x0);
... and then do the rest mentioned above (Attach(), CreateCompatibleDC(), SelectObject(), StretchBlt() etc.), I see only a greenish version of the image I want to blit (but in right aspect ratio, stride, dimension etc.), and it keeps appearing and disappearing with a blurry spot all the time.
What am I doing wrong?
Mac
|
|
|
|
|
From "CreateDIBSection Function"[^] documentation:
iUsage [in]
The type of data contained in the bmiColors array member of the BITMAPINFO structure pointed to by pbmi (either logical palette indexes or literal RGB values). The following values are defined.
Value Meaning
DIB_PAL_COLORS
The bmiColors member is an array of 16-bit indexes into the logical palette of the device context specified by hdc.
DIB_RGB_COLORS
The BITMAPINFO structure contains an array of literal RGB values.
Where's your array?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Friday, November 19, 2010 7:50 AM
|
|
|
|
|
I'd say it's not there...
lpInfo->bmiColors[0].rgbBlue=1;
lpInfo->bmiColors[0].rgbGreen=1;
lpInfo->bmiColors[0].rgbRed=1;
lpInfo->bmiColors[0].rgbReserved=0;
... is what I tried. I also iterated over 256 array indices, assigning 1 or 0. Which values do I have to assign? The blitted image looks different, but still more like a "pixel color accident".
Mac
|
|
|
|
|
It really depends on your DIB bits (of course you've to assign the whole array).
My naive attempt, would be:
for (int n=0; n < 256; n++)
{
lpInfo->bmiColors[n].rgbBlue=b;
lpInfo->bmiColors[n].rgbGreen=b;
lpInfo->bmiColors[n].rgbRed=b;
lpInfo->bmiColors[n].rgbReserved=0;
lpInfo->bmiColors[n].rgbBlue=n;
lpInfo->bmiColors[n].rgbGreen=n;
lpInfo->bmiColors[n].rgbRed=n;
lpInfo->bmiColors[n].rgbReserved=0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Tuesday, November 23, 2010 7:47 AM
|
|
|
|
|
When I do that, I run into an assertion (at some random point in my application), and in addition I sometimes get an "Out of memory" message.
When I assign only [0] through [9] of the array, I do get a blitted image like described in my original post, but with a very redish touch.
Mac
|
|
|
|
|
Pardon my dumb question: Do you know you should allocate enough memory for the array?
i.e.
BITMAPINFO *lpInfo = (BITMAPINFO *) (new BYTE[sizeof(BITMAPINFO) + 255 * sizeof(RGBQUAD)]);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|