home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / soclose.zip / soclose.pas < prev   
Pascal/Delphi Source File  |  2002-05-24  |  733b  |  45 lines

  1.  
  2. {$M 16384}
  3.  
  4. uses Inet, TpString;
  5.  
  6. var
  7.    sock                    :  Longint;
  8.    rc                       :  Longint;
  9.  
  10. procedure UsageExit;
  11. begin
  12.    WriteLn('Usage:   soclose Socket');
  13.    WriteLn;
  14.    Halt(20);
  15. end;
  16.  
  17. begin
  18.    WriteLn('soclose, (c) 2002 by madded2.'#13#10);
  19.  
  20.    if (ParamCount <> 1) or
  21.       not(Str2Long(ParamStr(1),sock)) then UsageExit;
  22.  
  23.    rc:=sock_init;
  24.    if rc <> 0 then
  25.    begin
  26.       WriteLn('sock_init failed, rc=',sock_errno);
  27.       Halt(1);
  28.    end;
  29.  
  30.    addsockettolist(sock);
  31.  
  32.    rc:=soclose(sock);
  33.    if rc = 0 then
  34.    begin
  35.       WriteLn('Socket ',sock,' closed.');
  36.       Halt(0);
  37.    end else
  38.    begin
  39.       WriteLn('soclose failed, rc=',sock_errno);
  40.       Halt(2);
  41.    end;
  42. end.
  43.  
  44.  
  45.