dsockcli.pp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Program Client;
  2. {
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {
  12. Dual socket client program. Before running this, run either
  13. 'isocksvr', 'dsocksvr' or 'dsocksvr -i' in another terminal
  14. or in the background.
  15. Make sure you run this with the same protocol as the server.
  16. }
  17. {$mode objfpc}{$H+}
  18. uses ssockets;
  19. Const
  20. TheSocket = 'ServerSoc';
  21. TheHost = 'localhost';
  22. ThePort = 4100;
  23. var
  24. Stream : TSocketStream;
  25. S : String;
  26. i : longint;
  27. begin
  28. S:='This is a textstring sent by the client'#10;
  29. If (ParamCount=1) and (paramstr(1)='-i') then
  30. Stream:=TInetSocket.Create(TheHost,ThePort)
  31. else
  32. Stream:=TUnixSocket.Create(TheSocket);
  33. With Stream do
  34. begin
  35. For I:=1 to 10 do
  36. Write(S[1],Length(S));
  37. S:='QUIT'#10;
  38. Write(S[1],Length(S));
  39. Free;
  40. end;
  41. end.