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