Advertisement
mixster

mixster

Jul 22nd, 2009
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.95 KB | None | 0 0
  1. var
  2.   s, c, c2, i: Integer;
  3.   col: TMessArr;
  4.   str: string;
  5.   hosts: TStringArray;
  6. begin
  7.   Writeln('Begin');
  8.  
  9.   s := CreateServerConnection(2022);
  10.   if (s = -1) then
  11.   begin
  12.     Writeln('Failed to create the server connection');
  13.     TerminateScript;
  14.   end;
  15.  
  16.   c := OpenConnection('127.0.0.1', 2022, 9000);
  17.   c2 := OpenConnection('127.0.0.1', 2022, 9000);
  18.  
  19.   SendConnectionData(c, 'Hello world!');
  20.   SendConnectionData(c2, 'How are you?');
  21.  
  22.   col := ReadServerData(s);
  23.  
  24.   for i := 0 to High(col) do
  25.     Writeln(col[i].host + ': ' + col[i].mess);
  26.  
  27.   if not SendServerData(s, 'localhost', 'I''m fine!') then
  28.   begin
  29.     Writeln('Failed to send data');
  30.     TerminateScript;
  31.   end;
  32.  
  33.   ReadConnectionData(c, str);
  34.   Writeln(str);
  35.  
  36.   hosts := GetServerClients(s);
  37.   for i := 0 to High(hosts) do
  38.     Writeln(IntToStr(i) + ' -> ' + hosts[i]);
  39.  
  40.   FreeConnection(c);
  41.   FreeConnection(c2);
  42.   FreeServerConnection(s);
  43.  
  44.   Writeln('End');
  45. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement