procedure TForm1.Button1Click(Sender: TObject); var tmps:string; begin tmps:='asdff'; ClientSocket1.Socket.SendBuf(tmps,length(tmps)); end;procedure TForm1.ServerSocket1ClientRead(Sender: TObject; Socket: TCustomWinSocket); var tmps:string; begin Socket.ReceiveBuf(tmps,Socket.ReceiveLength); ShowMessage(tmps); end;
TProcessBuf = record Count: Integer; Process: array[0..1024] of DWORD; FileName: array[0..1024] of string; end;如果我有这样一个结构,我怎么SendBuf呢?
TCustomWinSocket *Socket)
{
char *buff = new char[Socket->ReceiveLength()+1];
Socket->ReceiveBuf(buff,Socket->ReceiveLength());
ShowMessage(buff);
delete [] buff;
}
//---------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *buff = "asdff";
ClientSocket1->Active = true;
ClientSocket1->Socket->SendBuf(buff,strlen(buff));
}一个按钮button1,一个clientSocket1,一个ServerSocket1:object Form1: TForm1
Left = 354
Top = 195
Width = 420
Height = 317
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 128
Top = 144
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object ClientSocket1: TClientSocket
Active = True
ClientType = ctNonBlocking
Host = '127.0.0.1'
Port = 1234
Left = 64
Top = 40
end
object ServerSocket1: TServerSocket
Active = True
Port = 1234
ServerType = stNonBlocking
OnClientRead = ServerSocket1ClientRead
Left = 176
Top = 40
end
end
var
tmps:string;
begin
tmps:='asdff';
ClientSocket1.Socket.SendBuf(tmps,length(tmps));
end;procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
tmps:string;
begin
Socket.ReceiveBuf(tmps,Socket.ReceiveLength);
ShowMessage(tmps);
end;
Count: Integer;
Process: array[0..1024] of DWORD;
FileName: array[0..1024] of string;
end;如果我有这样一个结构,我怎么SendBuf呢?