Re: KB192570 done right: Asynchronous sockets in threads
- From: Tony Hill <tony.hill@xxxxxxxxxxxxxx>
- Date: Wed, 11 Apr 2007 20:25:19 +0100
I liked the essay (very informative) however when I downloaded the example and tried to compile it complained about some files it could not find in a common directory.
eg:
c1xx : fatal error C1083: Cannot open source file: '..\common\CONNECTS.CPP': No such file or directory
Is it me or is there something missing?
Joseph M. Newcomer wrote:
I have been thinking for some time of doing an example of asynchronous socket programming..
But I didn't seem to get motivated enough to do it. Alas, the Java example I'd taught in
2001 has been removed from the CMU Web site, so I couldn't just reference it.
That changed when I saw the atrocity KB192570, one of the single worst examples of
programming I've had the misfortune to see in a long time. I was so offended by an
example like this even existing that I simply had to rewrite it. I started out rewriting
it with commentary, but as I wrote more of it, it was clear that there was almost nothing
salvageable in the code. So I started over, largely by throwing away major pieces of the
code as I rewrote it, not bothering to record in the code the changes I made. After I was
done, I realized that I had eliminated most of the original lines.
I've now put it up on my site. It builds in VS6 and VS2005. It builds ANSI and Unicode
versions, for both Win32 and Win64 (in VS2005 only for Win64), uses UTF-8 for
transmission, is fully asynchronous, uses no synchronization primitives, will not lose
data, reports all errors, and...well, it actually works, unlike KB192570, which guarantees
that it will lose data, not report any errors, fail in a Unicode build, fails in a 64-bit
build, and pretty much gets sockets, threading, and synchronization completely wrong.
Given it was supposed to be an example of how to use sockets in threads, it is more than a
little unfortunate that it gets nothing right in any of those areas.
http://www.flounder.com/kb192570.htm
Before deciding to print it out, be warned that it takes about 70 pages. I got carried
away. It is probably over-documented, but the documentation is intended for beginners.
The UTF-8 conversion is described in
http://www.flounder.com/utf8.htm
The extensions of my ErrorString routine to handle WinSock errors is
http://www.flounder.com/formatmessage.htm#ErrorString%20for%20WinSock
joe
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Follow-Ups:
- References:
- KB192570 done right: Asynchronous sockets in threads
- From: Joseph M . Newcomer
- KB192570 done right: Asynchronous sockets in threads
- Prev by Date: Rename project
- Next by Date: Re: Embed Powerpoint window inside window / dialog
- Previous by thread: Re: KB192570 done right: Asynchronous sockets in threads
- Next by thread: Re: KB192570 done right: Asynchronous sockets in threads
- Index(es):
Relevant Pages
|