--- unix-server.pas	2004-04-27 14:45:35.000000000 +0200
+++ ip-server.pas	2004-05-03 22:42:52.000000000 +0200
@@ -1,33 +1,46 @@
-program Unix_server; { -*- mode:delphi; -*- }
-uses sockets,linux;
+program IP_server; { -*- mode:delphi; -*- }
+uses sockets,inet,linux;
 
 const
-   fileName = '/tmp/ukazkovySocket';
+   port	= 4456;      { Cislo portu na kterem budeme naslouchat }
 
-var
+var 
    s	    : longint;       { socket }
    sin,sout : text;          { pascalske proudy }
-   client   : string;
    i	    : integer;
    c	    : char;
    pid	    : longint;
    line	    : string;
+   addr	    : TInetSockAddr;
+
+function getName(addr :longint ):string;
+var
+   h  : THost;
+   a  : longint;
+begin
+   a:=NetToHost(addr);
+   h.AddressLookup(THostAddr(a));
+   getName:=h.Name;
+   h.done;
+end;
 
 begin
-   s:=socket(AF_UNIX,SOCK_STREAM,PF_UNIX);
+   s:=socket(AF_INET,SOCK_STREAM,0);
    if s=-1 then begin
       halt(1);
    end;
-   unlink(fileName);
-   if not bind(s,fileName) then halt(1);
+   addr.family:=AF_INET;  { Jedna se o adresu domeny INET, tj. IPv4 }
+   addr.port:=ShortHostToNet(port);
+   addr.addr:=0;          { Naslouchame na 0.0.0.0 tj. na vsech rozhranich }
+   if not bind(s,addr,sizeof(addr)) then halt(1);
    if not listen(s,5) then halt(1);
-   while accept(s,client,sin,sout) do begin
+   while accept(s,addr,sin,sout) do begin
       pid:=fork;
       if pid=-1 then halt(2);
       if pid=0 then begin
 	 reset(sin);
 	 rewrite(sout);
-	 writeln('Server: prichozi spojeni od:',client);
+	 writeln('Server: prichozi spojeni od:',getName(addr.addr));
 	 writeln(sout,'Mnauu');
 	 repeat
 	    readln(sin,line);
@@ -43,5 +56,4 @@
 	 halt(0);
       end;
    end;
-   unlink(fileName);
 end.
\ No newline at end of file
