Thursday, March 23, 2023

UDP CHAT

 unit Unit1;


{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, IdUDPServer,
  IdUDPClient, IdSocketHandle, IdGlobal;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    IdUDPClient1: TIdUDPClient;
    IdUDPServer1: TIdUDPServer;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
      const AData: TIdBytes; ABinding: TIdSocketHandle);
  private

  public

  end;

var
  Form1: TForm1;
  Msg: string;

implementation

{$R *.lfm}

{ TForm1 }



procedure TForm1.Button1Click(Sender: TObject);
begin
  IdUDPClient1.Send(Edit1.Text);
  Memo1.Lines.Add('You: ' + Edit1.Text);
  Edit1.Clear;
end;

procedure TForm1.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;
  const AData: TIdBytes; ABinding: TIdSocketHandle);
begin
  if BytesToString(AData) <> 'Hello' then begin
    ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, ToBytes(Byte(0)));
  end;
  Memo1.Lines.Add(ToHex(AData));
  Memo1.Lines.Add('ser>>'+BytesToString(AData));

  //Memo1.GoToTextEnd;
end;

end.


https://intellipaat.com/blog/database-partitioning-techniques









HOW TO FIND THE IP AND MAC ADDRESSES ON A LINUX COMPUTER

  1. In a terminal window, type "ifconfig -a" and press return.
  2. In the list of interfaces, find eth0.
  3. Locate the number next to HWAddr.

look at ether line.

On Windows in CMD type getmac command.

No comments:

Post a Comment

Beogradsko programiranje=