找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 4242|回复: 3

ACE_Asynch_Read_Stream 为什么所有的数据不能全传过去?

[复制链接]
发表于 2008-12-1 14:57:03 | 显示全部楼层 |阅读模式
int kk =0;
ACE_FILE_IO  io,iox;
ACE_FILE_Connector connector;
int k=  connector.connect (io,
  ACE_FILE_Addr ("MVSSService.doc"),
  0, // No timeout.
  ACE_Addr::sap_any, // Ignored.
  0, // Don't try to reuse the addr.
  O_RDONLY,
  ACE_DEFAULT_FILE_PERMS);
  connector.connect (iox,
  ACE_FILE_Addr ("MVSSService1.doc"),
  0, // No timeout.
  ACE_Addr::sap_any, // Ignored.
  0, // Don't try to reuse the addr.
  O_CREAT|O_WRONLY,
  ACE_DEFAULT_FILE_PERMS);
if ( k == -1)
{
  AfxMessageBox("服务器文件存在!");
  return k;
}
const size_t max_payload_size = 6*4 + 10*1024 + ACE_CDR::MAX_ALIGNMENT;

      

char array[10*1024];
MVSSNetMessage  mvssnetmessage;

BOOL  bWhile =1;


while(bWhile)
{
  kk = kk+1;

  
  bWhile =  io.recv(array,10*1024);
  ACE_OutputCDR payload(max_payload_size);
  //ACE_OutputCDR& payload = * ( new ACE_OutputCDR(max_payload_size));
  mvssnetmessage.arraylength = bWhile;
  strncpy(mvssnetmessage.writearray,array,bWhile);
  
  payload<<mvssnetmessage;
  ACE_CDR::ULong length = payload.total_length ();
  ACE_OutputCDR header(ACE_CDR::MAX_ALIGNMENT + 8);
  //ACE_OutputCDR &header = * (new ACE_OutputCDR(ACE_CDR::MAX_ALIGNMENT + 8));
  header << ACE_OutputCDR::from_boolean (ACE_CDR_BYTE_ORDER);
  header << ACE_CDR::ULong (length);
  
  ACE_Message_Block &blockx =
  /*block = */*header.begin()->clone();
  m_WriteStream.write(blockx,8);
  ACE_Message_Block &blocky= *payload.begin()->clone();
  m_WriteStream.write(blocky,length);
  CString str;
  //int x = payload.begin()->wr_ptr()-payload.begin()->rd_ptr();
  
}
io.close();
CString str;
str.Format("total transfer %d",kk);
AfxMessageBox(str);

return k;


return 0;
发表于 2008-12-1 16:32:50 | 显示全部楼层
上面什么是什么呀?搞不懂
 楼主| 发表于 2008-12-1 17:03:36 | 显示全部楼层

回复 #2 winston 的帖子

我想用proac tor 框架传文件
发表于 2008-12-1 21:40:31 | 显示全部楼层
这哪里有Proactor框架的影子啊?
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-12-23 21:56 , Processed in 0.019563 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表