Senin, 15 Juni 2015

Contoh Dasar Source Code Tcp Connection Exception Client

Berikut adalah Contoh Dasar Source Code Tcp Connection Exception Client dan sebelumnya juga mimin sudah bahas seputar Cara Buat Injek IdMappedPortTCP1 Digabungkan Dengan IDHTTP1 2015 ok dan berikut adalah contoh code delphinya yang bisa anda kembangkan kembali agar lebih baik dan silahkan disimak semoga listing code delphi sederhana ini bermanfaat dari mimin buat anda semuanya.

Tcp Connection Exception Client
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdThreadMgr, IdThreadMgrDefault, IdTCPServer, IdAntiFreezeBase,
  IdAntiFreeze, IdUDPBase, IdUDPClient, IdBaseComponent, IdComponent,
  IdTCPConnection, IdTCPClient, StdCtrls, ComCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    StatusBar1: TStatusBar;
    Memo1: TMemo;
    IdTCPClient1: TIdTCPClient;
    IdUDPClient1: TIdUDPClient;
    IdAntiFreeze1: TIdAntiFreeze;
    IdTCPServer1: TIdTCPServer;
    IdThreadMgrDefault1: TIdThreadMgrDefault;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure IdTCPServer1Execute(AThread: TIdPeerThread);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
   ServerIP:String;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 if not IdUDPClient1.Active then
 begin
  IdUDPClient1.Port:=8000;
  IdUDPClient1.BroadcastEnabled:=True;
  IdUDPClient1.Active:=True;
  IdTCPServer1.Active:=False;
 end;
 Button1.Enabled:=False;
 Button2.Enabled:=True;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 StrIn : String;
 StrOut : String;
begin
 StrOut:='Request';
 IdUDPClient1.Broadcast(StrOut, 8000);
 StrIn := IdUDPClient1.ReceiveString(50);
 if not (StrIn='') then
 begin
  Button3.Enabled:=True;
  Button2.Enabled:=False;
  Memo1.Lines.Add('UDP Reply');
  StatusBar1.Panels.Items[0].Text := 'Status : UDP Connected';
  ServerIP := StrIn;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
 StrIn : String;
begin
  if ServerIP<>'' then
  begin
   IdTCPClient1.Host := '10.1.89.130' ;
   IdTCPClient1.Port := 8000 ;
   IdTCPClient1.Connect;
   StrIn:= IdTCPClient1.ReadLn();
   //IdTCPClient1.Disconnect;
   if StrIn<>'' then
   begin
    Memo1.Lines.Add(StrIn);
    if StrIn<>'Reply' then
     StatusBar1.Panels.Items[0].Text :='Connected To TCPServer';
     Button3.Enabled:=False;
     Button1.Enabled:=True;
 end;
end;
end;

procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
 //check point
end;

end.
 
Kalau mau contoh source code yang jadinya silahkan bisa didownload DISINI via tusfiles dan itu saja info seputar Contoh Dasar Source Code Tcp Connection Exception Client 2015 terima kasih.

Selanjutnya;  Contoh Sederhana Code Delphi IdTcp Server Client