-Senden-
procedure TForm1.SendenClick(Sender: TObject);
var
I: Integer;
begin
TcpClient1.RemoteHost := edtRemoteHost.Text;
TcpClient1.RemotePort := edtRemotePort.Text;
if TcpClient1.Connect
then
begin
TcpClient1.Sendln(edtnickname.Text);
for I := 0
to memSend.Lines.Count - 1
do
TcpClient1.Sendln(memSend.Lines[I]);
end;
TcpClient1.Disconnect;
for I := 0
to memSend.Lines.Count - 1
do
memsend.Lines.Delete(I);
end;
-Empfangen-
procedure TForm1.TcpServer1Accept(sender: TObject;
ClientSocket: TCustomIpClient);
var
s:
string;
nick:
string;
DataThread: TClientDataThread;
begin
// create thread
DataThread:= TClientDataThread.Create(true);
// set the TagetList to the gui list that you
// with to synch with.
DataThread.TargetList := memRecv.lines;
// Load the Threads ListBuffer
nick := ClientSocket.Receiveln;
s := ClientSocket.Receiveln;
while s <> '
'
do
begin
DataThread.ListBuffer.Add( nick + '
-' + TimeToStr(Time) +'
@' + ClientSocket.RemoteHost + '
');
DataThread.ListBuffer.Add(s);
s := ClientSocket.Receiveln;
end;
// Call Resume which will execute and synch the
// ListBuffer with the TargetList
DataThread.Resume;
memrecv.Perform(EM_SCROLLCARET, 0, 0);
end;