unit Chat_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Sockets;
type
TForm2 =
class(TForm)
MemoRecive: TMemo;
EdNick: TEdit;
EdIp: TEdit;
EdPort: TEdit;
BtnSend: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
BtnConnect: TButton;
ClientSocket: TTcpClient;
Memosend: TEdit;
Button1: TButton;
procedure BtnConnectClick(Sender: TObject);
procedure ClientSocketReceive(Sender: TObject; Buf: PAnsiChar;
var DataLen: Integer);
procedure FormCreate(Sender: TObject);
procedure BtnSendClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
end;
var
Form2: TForm2;
EdPort :
string ;
implementation
{$R *.dfm}
procedure TForm2.BtnConnectClick(Sender: TObject);
begin
begin
ClientSocket.RemoteHost:=EdIP.Text;
//Die IP wird festgelegt
ClientSocket.RemotePort:= EdPort.text;
//Der Port wird festgelegt
ClientSocket.Open;
//Verbindung zum Server wird hergestellt
//if ClientSocket.connected = true then
begin
BtnSend.Enabled := true;
MemoRecive.Lines.Add('
Verbunden')
end
// else
// Memorecive.Lines.Add('Verbindung konnte nicht hergestellt werden.');
end;
end;
procedure TForm2.BtnSendClick(Sender: TObject);
begin
if ClientSocket.ACTIVE = true
then
ClientSocket.Sendln(Memosend.Text)
else
Memorecive.Lines.Add('
Nicht verbunden')
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
Clientsocket.Sendln(Memosend.Text)
end;
procedure TForm2.ClientSocketReceive(Sender: TObject; Buf: PAnsiChar;
var DataLen: Integer);
begin;
MemoRecive.Lines.Add(clientsocket.Receiveln());
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
BtnSend.Enabled := false;
end;
end.