sockcli.pp 848 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. Program Client;
  2. {
  3. Program to test Sockets unit by Michael van Canneyt and Peter Vreman
  4. Client Version, First Run sock_svr to let it create a socket and then
  5. sock_cli to connect to that socket
  6. }
  7. uses Sockets,Linux;
  8. procedure PError(const S : string);
  9. begin
  10. writeln(S,SocketError);
  11. halt(100);
  12. end;
  13. Var
  14. Saddr : String[25];
  15. Buffer : string [255];
  16. S : Longint;
  17. Sin,Sout : Text;
  18. i : integer;
  19. begin
  20. S:=Socket (AF_UNIX,SOCK_STREAM,0);
  21. if SocketError<>0 then
  22. Perror('Client : Socket : ');
  23. Saddr:='ServerSoc';
  24. if not Connect (S,SAddr,Sin,Sout) then
  25. PError('Client : Connect : ');
  26. Reset(Sin);
  27. ReWrite(Sout);
  28. Buffer:='This is a textstring sent by the Client.';
  29. for i:=1 to 10 do
  30. Writeln(Sout,Buffer);
  31. Flush(Sout);
  32. Readln(SIn,Buffer);
  33. WriteLn(Buffer);
  34. Close(sout);
  35. end.