|
Thx for your will to help.
That's what I was relying on, but this way I needed to get all flags in the resources which was tedious.
I found this which solves my issue and maybe the one who would encontere the same situation :
http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1707
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
Hey guys,
I am trying to fetch the data from here ->
http://74.54.176.106/whois/whois.cgi?domain=127.0.0.1[^]
Though I am not receiving everything, this is all I get:
<HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt;Global Whois : whois 127.0.0.1
Tried to google but couldn't find anything that helped me.
my code:
char buffer[4096];
char strRequest[] = "GET /whois/whois.cgi?domain=127.0.0.1 / HTTP/1.0\r\n\r\n";
send(sock, strRequest, sizeof(strRequest), 0);
int i = recv(sock, buffer, sizeof(buffer), 0);
modified on Friday, November 26, 2010 11:49 AM
|
|
|
|
|
Please try to correct the "code block" so readers can understand.
You supplied a buffer length that good enough.
However you should note that the socket :recv API does not garantee to you the receipt of all incoming data at once.
You must loop on that function untill either the peer server closes the connection (I think you will get a -1 return value from recv)
or until you know that you received what you "want" ( can only be done if you decode and interpret data at same time ).
Let me suppose that you are talking to a peer webserver, so we know that when all data is sent, the server immediately closes the connection. In that case, your code
should be like this :
char buffer[4096];
int offset = 0;
while ( true )
{
int i = recv(sock, buffer+offset, sizeof(buffer)-offset, 0);
if(i != -1){
offset += i;
else
break;
}
It is the same thing with the ::send API. You can not garantee that all passed data will be sent. In both cases the system will give you the count of what it managed to process.
Of course you can help avoid these complexities but just using an existing library.
Hope this helps.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
Thanks, I got where you are coming from.
Unfortunately the connection doesnt close, it just sits there.
Tried sending
char strRequest[] = "GET /whois/whois.cgi?domain=127.0.0.1 HTTP/1.0\r\nConnection: Close\r\n\r\n";
but nothing.
Can you suggest me an already existing library that isn't as huge as curlpp or boost, or generally one that is somewhat easy to handle?
I am still new to c++ as you may know.
modified on Friday, November 26, 2010 12:13 PM
|
|
|
|
|
Use Poco C++. I used it before eventhough I personaly did not touch the network library of it. (consists of 3 dlls maybe you just need the network one only).
If I remember well there was a class called HttpClient so it will automatize your task.
There are test suites as well so you can figure how things are being used and even take your decision of whether to use the library or not.
http://pocoproject.org/
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
You need to study the rules of sockets. A recv() call will only return the amount of data that is currently available on the socket. You must continue to receive data until you get the end of the transmission (I cannot remember the last piece of an HTTP message, but I'm sure you can Google it). Don't just assume you will get the entire message in one go.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hello people.
I have a tooltip-like system that shows up information in a popup window based on where the mouse cursor points. Works fine most of the time, but when there's a message box or other modal dialog popping up because of certain events hapening in the background, the tooltip windows just stays on the screen. I guess this is because once the parent window containing the control that has the tooltips is deactivated/disabled (because of the modal dialog), it no longer receives any mouse messages thus the "tooltip" will think that the mouse is still pointing at the given location (since there's no WM_MOUSEMOVE, no WM_MOUSELEAVE...). I used the usual mouse messages (WM_MOUSEMOVE, WM_LBUTTONDOWN...) along with TrackMouseEvent[^] to know when and what to show and hide. But i don't know how to handle the case when we no longer receive any mouse input. One way i guess would be to handle WM_ACTIVATE in the parent window and then channel the event towards the child that has the tooltips but this seems to be quite a non-portable and ugly solution. So anyone knows how to do this right?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Hi there,
So what about just intercepting the event of when that parent window gets de-activated because of the pop-up and force to tooltip to disappear ?
You may thus look for WM_ACTIVATE event. Its handler gives a state parameter by which you know if your window is being activated or deactivated, and in the second case it can even give you the address of the "guilty" window (the popups in your case)
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
As i said, that is one option, it just seems a bit...ugly. Having to do that for every "parent" window everywhere you want to use this tooltip thing isn't convenient.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
Sorry I looked to your message rapidly, not paying attentio,n to your last sentence.
Well, I do'nt thiink it is too ugly. By the way, you are already calling your tooltip from within the parent frame, in order to achieve things like the tooltip fades away when mouse leaves the control area, no ?
I honestly can't see something else. I had this pbm before with Pustovoy' tooltip when popus are triggered by hyperlinks on the tooltip themselves.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
No, i use TrackMouseEvent[^] to detect when the mouse leaves. Guess i'll have to go with the activation "relaying" then. Thanks for your help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world.
Fry: But this is HDTV. It's got better resolution than the real world <
|
|
|
|
|
void getPath(LPSTR lpszPath)
{
CFile file;
char pbuf[512];
...
file.Read(pbuf, size);
}
So what can I do to manage it?
Maybe what has confused me is the different string data types....
|
|
|
|
|
It is the same as if you were dealing with char* !
Have the habit of discovering what the definition of an unknwon type to you is. In this case you'll find it's just made from a typedef !
typedef CHAR *LPSTR;
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
|
LPSTR is a char*
typedef char* PSTR, *LPSTR;
|
|
|
|
|
|
#include "stdafx.h"
#include <iostream>
#include "afx.h"
using namespace::std;
void getPath(LPSTR lpszPath, int max)
{
char pbuf[512];
LPCTSTR lpszFileName = _T("1.txt");
CFile mFile(lpszFileName, CFile::modeRead | CFile::shareCompat);
if(mFile.GetLength() < 2)
return;
mFile.Read(pbuf, 500);
mFile.Close();
memcpy(lpszPath, pbuf, 500);
}
int _tmain(int argc, _TCHAR* argv[])
{
LPSTR lpstr = new char[2000];
memset(lpstr, 0, 2000);
getPath(lpstr, 2000);
return 0;
}
我爸是李刚
|
|
|
|
|
thx for your detailed example
|
|
|
|
|
|
Hi all,
i dont know can can this happen,after running some time my application is fully black,no control or gui display here.
please tell me what can i do for this.
thanks in advance.
|
|
|
|
|
Please switch ON the monitor again.
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]
|
|
|
|
|
monitor is on and other application are fine visible.
|
|
|
|
|
You maight read my answer this way:
You should elaborate: with the provided info we couldn't even guess what is happening with your application.
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]
|
|
|
|
|
With his monitor off, he can't read your advice anyway.
|
|
|
|
|
Luc Pattyn wrote: With his monitor off, he can't read your advice anyway.
The joke was on the line of: "dumb question -> dumb answer".
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]
|
|
|
|