unit chatpas;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Winsock, ScktComp, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP, IdHTTP;
type
TForm1 =
class(TForm)
Memo1: TMemo;
Message: TLabel;
Sendtext: TEdit;
Send: TButton;
Connect: TButton;
ListBox1: TListBox;
Nicknametext: TEdit;
Nickname: TLabel;
ListBox2: TListBox;
ServerSocket1: TServerSocket;
ClientSocket1: TClientSocket;
IdHTTP1: TIdHTTP;
procedure ConnectClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Memo1.Lines.Delete(0);
end;
function GetLocalIPs(
const Lines:TStrings):Boolean;
type
PPInAddr= ^PInAddr;
var
wsaData: TWSAData;
HostInfo: PHostEnt;
HostName:
Array[0..255]
of Char;
Addr: PPInAddr;
begin
Result:=False;
Lines.Clear;
if WSAStartup($0102, wsaData)=0
then
try
if gethostname(HostName, SizeOf(HostName)) = 0
then Begin
HostInfo:= gethostbyname(HostName);
if HostInfo<>
nil then Begin
Addr:=Pointer(HostInfo^.h_addr_list);
if (Addr<>
nil)
AND (Addr^<>
nil)
then
Repeat
Lines.Add(StrPas(inet_ntoa(Addr^^)));
inc(Addr);
Until Addr^=nil;
end;
end;
Result:=True;
finally
WSACleanup;
end;
end;
procedure TForm1.ConnectClick(Sender: TObject);
var idhttp1: TIdhttp;
parameter: TStringlist;
begin
if not GetLocalIPs(Listbox2.Items)
then
MessageDLG('
Keine IP-Adresse',mtInformation,[mbOK],0);
Parameter:=TStringlist.Create;
idhttp1 := TIdhttp.Create(
nil);
parameter.Add('
nickname=nicknametext.text');
parameter.Add('
ip=listbox1.items(0)');
idhttp1.Post('
http://sbinder.sb.funpic.de/users.php', parameter);
idhttp1.Free;
end;
end.