Total members 11894 |It is currently Sat Nov 23, 2024 9:12 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





1.Client
procedure TForm1.ButtonKoneksiClick(Sender: TObject);
begin
if ClientSocket1.Active then
begin
ClientSocket1.Active := false;
end
else
begin
ClientSocket1.Address := EditIPServer.Text;
ClientSocket1.Port := StrToInt(EditPortServer.Text);
ClientSocket1.Active := true;
end;
end;

procedure TForm1.ClientSocket1Connecting(Sender: TObject;
Socket: TCustomWinSocket);
begin
LabelStatusKoneksi.Caption := 'Mencoba koneksi ke server';
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
LabelStatusKoneksi.Caption := 'Terkoneksi ke server';
ButtonKoneksi.Caption := 'Putuskan Koneksi'
end;

procedure TForm1.ClientSocket1Disconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
LabelStatusKoneksi.Caption := 'Tidak terkoneksi ke server';
ButtonKoneksi.Caption := 'konek ke server';
end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
LabelStatusKoneksi.Caption :=
'Terjadi error saat koneksi ke server';
ErrorCode := 0;
end;

procedure TForm1.ButtonkirimClick(Sender: TObject);
begin
if ClientSocket1.Active then
ClientSocket1.Socket.SendText(EditData.Text)
else
ShowMessage('Koneksi tidak aktif');
end;

end.

2.Server
procedure TForm1.ButtonJalankanClick(Sender: TObject);
begin
if ServerSocket1.Active then
begin
ServerSocket1.Active := false;
LabelStatusServer.Caption := 'Server tidak aktif';
ButtonJalankan.Caption := 'Jalankan server';
end
else
begin
ServerSocket1.Port := StrToInt(EditPortServer.Text);
ServerSocket1.Active := true;
LabelStatusServer.Caption := 'Server aktif mendengarkan klien';
ButtonJalankan.Caption := 'Matikan server';
end;
end;

procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
LabelKlien.Caption := 'Klien terkoneksi dari'+ Socket.RemoteAddress;
end;

procedure TForm1.ServerSocket1ClientDisconnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
LabelKlien.Caption := 'Tidak ada klien terkoneksi';
end;

procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(Socket.ReceiveText);
end;

end.




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : please get me the following Delphi to Java conversion
 .dll conversion     -  
 Type Conversion     -  
 Number Conversion     -  
 ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)     -  
 SUCCESSIVE APPROXIMATION ANALOGUE TO DIGITAL CONVERSION     -  
 conversion from binary to decimal numbers as string     -  
 2d game in java-Monster-Java 2D Game Graphics and Animation     -  
 Using FTP in java     -  
 what is java     -  
 Java course     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com