winsockapi_wrappers.shtml

来自「mfc资源大全包含MFC编程各个方面的源码」· SHTML 代码 · 共 43 行

SHTML
43
字号
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Zafir Anjum">
   <TITLE>Internet - Winsock API Wrapper Classes</TITLE>
</HEAD>
<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323" alink="#FF0000">
<table WIDTH="100%">
<tr WIDTH="100%">
<td align=center><!--#exec cgi="/cgi/ads.cgi"--><td>
</tr>
</table>


<CENTER><H3><FONT COLOR="#AOAO99">Winsock API Wrapper Classes</FONT></H3></CENTER>
<HR>


<p>This sample was contributed by <a href="mailto:poul@wizsoft.com">Poul A Costinski</a></p>

<P>Creating multithreaded TCP/IP server - one like WWW server -:)
for NT becomes frequent task novadays. MFC supplies several socket
classes, but, from my experience, they are just unusable for this purpose.
They fail all the time, and several 1000s (!) times slower than raw Winsock
interface.

<P>Facing the challenge, I wrote my own thin wrapper classes around socket API,
together with template for server, and it was surprisingly simple.

<P>The complete example project is in file RawSocketServerExample.ZIP.

<P>Several notes for class usage:

<P>Server's thread dispatcher for client-server environment.

<H4>Class CWizThreadDispatcher.</H4>

Uses pure virtual helper class CWizMultiThreadedWorker.
Serves regular situation when requests come from many clients to the
server.
<P>Dispatcher starts to serve the client in the separate thread and continues to
wait for requests. The number of parallel threads is limited for
effectiveness. The actual work (whatever it is)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?