unit CChatServer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ScktComp, StdCtrls;
type
TCC =
class(TForm)
ServerSocket1: TServerSocket;
procedure FormCreate(Sender: TObject);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
CC: TCC;
implementation
{$R *.dfm}
procedure TCC.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var msg:
String;
i : Integer;
begin
msg:= Socket.ReceiveText;
//Empfangene Nachricht wird in "msg" gespeichert
for i := 0
to ServerSocket1.Socket.ActiveConnections-1
do
//Die Nachricht wird an alle verbundenen Clients gesendet
ServerSocket1.Socket.Connections[i].SendText(msg);
end;
procedure TCC.FormCreate(Sender: TObject);
begin
ServerSocket1.Open;
end;
end.