一个演示 CAsyncSocket 用法的极简单的例子.

 

 不到 100 行代码. 实现服务器, 客户端. 如果带有命令行参数, 则为服务器, 否则是客户端.

vc6 下编译. 环境变量中, 确保 cl.exe 在 PATH 中, INCLUDE 包含 vc6 头文件目录. LIB 包含库文件目录.

D:/>set path
Path=C:/WINDOWS/system32;C:/WINDOWS;C:/WINDOWS/System32/Wbem;C:/Program Files/Mi
crosoft Visual Studio/Common/Tools/WinNT;C:/Program Files/Microsoft Visual Studi
o/Common/MSDev98/Bin;C:/Program Files/Microsoft Visual Studio/Common/Tools;C:/Pr
ogram Files/Microsoft Visual Studio/VC98/bin;C:/WINDOWS/system32;C:/WINDOWS;C:/W
INDOWS/System32/Wbem;C:/JBuilderX/jdk1.4/bin;C:/JBuilderX/jdk1.4/jre/bin;c:/debu
ggers;d:/program files/system internals;d:/program files
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

D:/>set in
include=C:/Program Files/Microsoft Visual Studio/VC98/atl/include;C:/Program Fil
es/Microsoft Visual Studio/VC98/mfc/include;C:/Program Files/Microsoft Visual St
udio/VC98/include

D:/>set li
lib=C:/Program Files/Microsoft Visual Studio/VC98/mfc/lib;C:/Program Files/Micro
soft Visual Studio/VC98/lib

D:>cl -GX -MTd asyncsock3.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

asyncsock3.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:asyncsock3.exe
asyncsock3.obj

如果用 IDE 打开, 需要修改编译参数.

源码下载

 

 

 

 

你可能感兴趣的:(一个演示 CAsyncSocket 用法的极简单的例子.)