windows 网络编程笔记 winsocket API CSocket CAsyncSocket

这篇博客探讨了MFC中对SOCKET编程的支持,尤其是CAsyncSocket和CSocket类的应用。文章指出,尽管MFC提供了支持,但其文档不清晰导致开发者更倾向于使用winsocket API。文中详细解释了如何在非阻塞和阻塞模式间切换,并通过代码示例展示了CSocket类在收发文件时的行为。
摘要由CSDN通过智能技术生成

MFC对SOCKET编程的支持其实是很充分的,然而其文档是语焉不详的。以至于大多数用VC编写的功能稍
复杂的网络程序,还是使用API的。故CAsyncSocket及CSocket事实上成为疑难,群众多敬而远之。余
好事者也,不忍资源浪费,特为之注解。网友关于阻塞、非阻塞等的说法不是很可信。

====================================================

1.  MSDN winsocket API 函数说明:

int WSAAsyncSelect(
  __in          SOCKET s,
  __in          HWND hWnd,
  __in          unsigned int wMsg,
  __in          long lEvent
);

The WSAAsyncSelect function is used to request that WS2_32.DLL should send a message to the window hWnd when it detects any network event specified by the lEvent parameter. The message that should be sent is specified by the wMsg parameter. The socket for which notification is required is identified by the s parameter.


The WSAAsyncSelect function automatically sets socket s to nonblocking mode, regardless of the value of lEvent. To set socket s back

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值