解决方案 »
- COleDateTime //时间类型与CTime不一样吗?????
- CSocket的函数在哪里???
- IE ATL编程菜鸟请教 有个微软的例程 不知道如何修改
- 为什么在多线程调用的函数中 HRESULT hres = CoInitializeEx(0, COINIT_MULTITHREADED); 失败?
- 如何自动检测是哪个串口
- <<<- ---- - - - - - - - - -- - -- -- >>>为什么 插入DLL到QQ 也无法取得其 密码框 的内容?
- 请高手给我解释一下这段代码是怎么工作的。
- 如果更改应用程序的open/save对话框的缺省目录?
- 如何在对话框上输出内容?
- 求救
- error C2106: “=”: 左操作数必须为左值的问题,环境是VC2010,代码如下:
- 卖过滤机回来,小赚一笔,觉得还是不回去做程序了。
int SendHunk(SOCKET h,char *lpBuf,int nBufLen)
{
int nSend = -1 ;
int nSendAll = 0;
if( h != SOCKET_ERROR && lpBuf != NULL && nBufLen > 0 )
{
//循环发送,直到所有数据都发送完毕或出错就返回
do {
nSend = ::send(h, //已经连接的句柄
lpBuf+nSendAll, //跳过已经发送的数据
nBufLen-nSendAll, //计算剩余要发送的数据长度
0);
if( nSend > 0 )
nSendAll +=nSend;//累加已经成功发送的数据长度
else
break;
} while( nSendAll < nBufLen );
}
return nSendAll;
}//接收数据
int RecvHunk(SOCKET h,char *lpBuf,int nBufLen,int nWillLen)
{
int nRecv = -1 ;
int nRecvAll = 0; if( h != SOCKET_ERROR && lpBuf != NULL && nBufLen > 0 && nWillLen >0 && nBufLen >= nWillLen )
{
//循环接收,直到数据达到要接收的长度或出错就返回
do { nRecv = ::recv(h, //已经连接的句柄
lpBuf+nRecvAll,//跳过已经接收的数据
nWillLen-nRecvAll,//计算剩余要接收的数据长度
0);
if( nRecv >0 )
nRecvAll = nRecv;//当前已经接收的长度
else
break;
} while( nRecvAll < nWillLen );
} return nRecvAll;
}