njf_3829 发表于 2008-12-1 14:57:03

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

int kk =0;
ACE_FILE_IOio,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;
MVSSNetMessagemvssnetmessage;

BOOLbWhile =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;

winston 发表于 2008-12-1 16:32:50

上面什么是什么呀?搞不懂

njf_3829 发表于 2008-12-1 17:03:36

回复 #2 winston 的帖子

我想用proac tor 框架传文件

winston 发表于 2008-12-1 21:40:31

这哪里有Proactor框架的影子啊?
页: [1]
查看完整版本: ACE_Asynch_Read_Stream 为什么所有的数据不能全传过去?