没有那么麻烦吧?
//客户端(发送数组代码):
void __fastcall TClientForm::Button2Click(TObject *Sender)
{
const int dim = 2048;
int ar[dim],rs,sz;
for (int i=0; i<dim; i++){
ar = i;
}
sz = sizeof(ar);
rs = CliSock->Socket->SendBuf(&ar, sz);
if (rs>=sz){
ShowMessage("发送成功!");
for (int i=0; i<dim; i++)
Memo1->Lines->Add(IntToStr(ar));
}
else
ShowMessage("发送失败!");
}
//服务器端(OnClientRead事件):
void __fastcall TServerForm::SvrSockClientRead(TObject *Sender,
TCustomWinSocket *Socket)
{
const int dim = 2048;
int ar[dim],sz,rs;
sz = sizeof(ar);
rs = Socket->ReceiveBuf(&ar, sz);
if (rs>0){
for (int i=0; i<dim; i++)
Memo1->Lines->Add(IntToStr(ar));
}else
ShowMessage("接收失败!");
}