|
When you create sockets in Windows using SDK functions, they are generally blocking, meaning that if no data is available for a receive, the application would hang until data is ready.
However, the CAsyncSocket class hides a lot of implementation details from you. When you create a socket based on this class, the calls are non-blocking. The idea is that your program will respond to networking events, rather than waiting for something to happen.
Receiving "WSAEWOULDBLOCK" is more of an informational message than an error. All it is telling you is that if you were using the blocking version of that function, it would be blocking right now.
What you should do is create a subclass of CAsyncSocket, and overload the "OnReceive" function. Any time data is available from the network, this function is called. You can put it in your screen buffer and display it at that point.
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Thank you VERY much, it worked perfectly
Sprudling
|
|
|
|
|
You're welcome! I just spent the past few days working with MFC's CAsyncSocket class, so I through I might be able to help
--
Paul
"I drank... WHAT?"
|
|
|
|
|
Hi Friends
I need some help I want to Execute a Dos Command , not a one shot one. Eg ftp,
Say ftp xxxx , then it will ask for the username , then I want to pass it , then the password? How to do this from a C++ Programe, remember ftp is just a Example , I need a generalized solution which I can use in this type of situations.
Thanks
Gaurika Wijeratne..
Gaurika Wijeratne .. www.gaurika.com
|
|
|
|
|
You can use "<" to redirect input.
eg:-
D:\>copy con abc.txt
d100
q
^Z
1 file(s) copied.
D:\>debug < abc.txt
-d100
0B00:0100 4D 8B 56 05 80 FA 00 74-05 80 FE 3A 74 02 B2 40 M.V....t...:t..@
0B00:0110 80 CA 20 80 EA 60 E8 74-E4 73 06 E8 34 00 EF 0A .. ..`.t.s..4...
0B00:0120 D8 8B D5 83 C2 05 8A 7E-04 80 E7 06 80 FF 06 75 .......~.......u
0B00:0130 18 8B 76 02 B3 3A 38 5C-FE 75 06 C6 46 00 02 EB ..v..:8\.u..F...
0B00:0140 05 C6 46 00 01 4E E9 83-00 80 FF 02 75 05 C6 46 ..F..N......u..F
0B00:0150 00 00 C3 E8 B6 EB B4 3B-CD 21 72 39 8B FA 33 C0 .......;.!r9..3.
0B00:0160 8B C8 49 26 8A 05 47 0A-C0 74 0C 32 E4 E8 23 E2 ..I&..G..t.2..#.
0B00:0170 74 F1 47 FE C4 EB EC 4F-A0 03 96 C6 46 00 02 0A t.G....O....F...
-q
D:\>
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Take a look at CreateProcess() in your docs.
cheers,
-Ben
|
|
|
|
|
eheheh!!
I don't think that's right, because in this case ... try it:
#include "stdio.h"
template < class type > int size(){return sizeof(type);};
int main(int argc, char* argv[])
{
printf("%i\n",size <float>());
printf("%i\n",size <int>());
printf("%i\n",size <double>());
printf("%i\n",size <char>());
printf("%i\n",size <short>());
};
Why???
Gianfranco Lanzetta.
|
|
|
|
|
Works fine for me with VC7.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
Works fine for me with VC7.
Tim,
I think he can compile it and run it, but that he is not fully satisfied with the outputs he got.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
What is wrong with the output. I got all the numbers I expected.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
What is wrong with the output. I got all the numbers I expected.
I believe his expectations don't match those of yours.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
Yeah, looking at the code again, I ran into this bug with VC6. Fixed in VC7.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
|
I haven't installed any VC7 patches.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
If all you are getting is 4 or 2 for each of the types, this is a known bug I reported to MS with template functions that don't have unique types in the arguments.
This bug is fixed in VC7. Don't hold your breath for a patch to VC6.
The workaround is to use structs and not functions.
template <class _T>
struct sizer
{
int sizer () { return sizeof (_T); }
};
printf ("%d", sizer<int>::sizer ());
I think that will do it, but I didn't test it.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Some Window Engine in this page is very good (use API function: WindowFromPoint()) . But I can't use it for my purpose:
-Get handle of a "static " (label) created in Visual Basic 6.0.
It seems VB label is drawn onto screen, not be a control (so you can't get its handle).
Can you give me an answer ?
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
dlhson wrote:
It seems VB label is drawn onto screen, not be a control
I think the VB label is a STATIC control. I might be wrong here. But that's my impression.
Nish
The rumours that I am an AI bot are absolutely false. These rumours have been propogated by *them* to focus all the attention on to me, while *their* bots take over the planet. Thank y%%%% Divide by zero. Cannot proceed. Abort(y/y)?
|
|
|
|
|
You are correct, the VB label is not a control. The form draws it. My guess this is to reduce the number of controls that VB programmers place on a form, since you are only allowed to have 255 declared in a resource file.
What purposes do you want to have the handle to the label in VB? Depending on what you plan on doing, there are options.
Checkout my Guide to Win32 Paint for Intermediates
|
|
|
|
|
control.hwnd
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I'm sorry I thinked that you was talking about VB...
If you want to Know the HWND of the label, you must to use the label like a CWnd, and asign it with CWnd::GetDlgItem. You can get the handle with the data memeber CWnd::m_hWnd...;)
Best Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
I've been tinkering a little with STL after my brief run-in with the map template the other week. It took me a while to recover from that episode; but i've been having a go with the string thing.
My current program users c strings (char arrays, not that mfc bunk). I can already hear Christian muttering in the background. I used them becuase my program has the following traits:
-> lots of scanf and sprintf type stuff goes on, to jam integers to and from strings.
-> I'm using sockets and use char pointers to muck about with the input buffer that i receive through my socket.
-> one part of my program decodes a mime- formatted email body. as you may know, this is a hierarchical structure where a section consists of a header and a body. a body could also be a section in it's own right, consisting of a header and a body. Right now, i start with one big char pointer, and i call a function recursively on each body section to decode. This makes extensive use of tricking a c-type string into multiple separate strings by sticking \0 in the correct places.
I'm worried that reimplementing my program using stl is going to be a nightmare. Can someone please explain to me how it will in fact be a delightful process instead.
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I have done a lot of the same stuff that you are doing, and I started to change my program from char pointers to std::string
Performance was, err.., one third, and it was a nightmare to change the program. std::string is way too slow for extensive string-stuff
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have to agree with Anders. For dynamic string intensive stuff, char arrays work best. For general string storage and lightweight processing, std::string is the way to go.
I use both extensively.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
One minor clarification.
If your string intensive stuff just results in always having to reallocate storage space to support changes in the string, then std::string should work just fine too.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I read an article in CUJ or DDJ (can't remember which) last fall which dealt with these performance problems.
One solution (using storage trade-offs) was to create a std::string compatible class called something like fixed_string. fixed_string would then implement the string using a fixed length char array. You got the best of both worlds: speed and the nice std::string interface.
The article also mentioned how you could pool these strings to optimize the performance even more (mostly for threaded environments).
I'm sorry I can't give you a correct reference to the article, my magazines are at home, and I'm not online at home anymore
Sonorked as well: 100.13197 jorgen
FreeBSD is sexy.
|
|
|
|