unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 =
class(TForm)
ClientSocket1: TClientSocket;
Memo1: TMemo;
ServerSocket1: TServerSocket;
Memo2: TMemo;
CheckBox1: TCheckBox;
procedure CheckBox1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocket1ClientWrite(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
CTDaten =
record //Record des Clienten
Name:
string[60];
Zahl: integer;
end;
type
STDaten =
record // leerer Record des Servers
Name:
string[60];
Zahl: Integer;
end;
var
Form1: TForm1;
CLDaten: CTDaten;
SRDaten: STDaten;
implementation
{$R *.dfm}
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
clientsocket1.Active := checkbox1.Checked;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
clDaten.
Name := '
Marko';
clDaten.Zahl := 123456455;
//unseren Client-Record füllen
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo1.Lines.Add(inttostr(sizeof(cldaten)));
// Wie groß ist der Record.
clientsocket1.Socket.SendBuf(cldaten, sizeof(cldaten));
//Record abschicken
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
ServerSocket1.Socket.Connections[0].ReceiveBuf(srdaten,sizeof(srdaten));
memo1.Lines.Add(srdaten.
Name);
//schauen ob alles angekommen ist ;)
memo1.Lines.Add(inttostr(srdaten.Zahl));
end;
end.