Difference between revisions of "TCPFree"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> function TCPFree(const iTCPClient: Integer): Boolean; </source> ==Availability== SCAR Divi 3.26 > Current ===Aliases=== *FreeC...")
 
 
Line 25: Line 25:
 
   i := TCPConnect('irc.scar-divi.com', 6667, 1000);
 
   i := TCPConnect('irc.scar-divi.com', 6667, 1000);
 
   try
 
   try
     TCPWrite(i, 'NICK ' + Nick);
+
     TCPSend(i, 'NICK ' + Nick);
     TCPWrite(i, 'USER ' + Nick + ' 0 * :' + Nick);
+
     TCPSend(i, 'USER ' + Nick + ' 0 * :' + Nick);
     TCPWrite(i, 'JOIN #scar');
+
     TCPSend(i, 'JOIN #scar');
 
     while Running do
 
     while Running do
 
     begin
 
     begin
       TCPRead(i, s);
+
       TCPReceive(i, s);
 
       if s = '' then
 
       if s = '' then
 
         Wait(500)
 
         Wait(500)
Line 37: Line 37:
 
       if Pos('= #scar', s) > 0 then
 
       if Pos('= #scar', s) > 0 then
 
       begin
 
       begin
         TCPWrite(i, 'PRIVMSG #scar :Hello World!');
+
         TCPSend(i, 'PRIVMSG #scar :Hello World!');
 
         Running := False;
 
         Running := False;
 
       end;
 
       end;
Line 50: Line 50:
 
*[[TCPConnect]]
 
*[[TCPConnect]]
 
*[[TCPConnected]]
 
*[[TCPConnected]]
*[[TCPRead]]
+
*[[TCPReceive]]
*[[TCPWrite]]
+
*[[TCPSend]]
  
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Internet Functions]]
 
[[Category:Internet Functions]]
 
[[Category:TCP Functions]]
 
[[Category:TCP Functions]]

Latest revision as of 10:31, 4 July 2011

Definition

function TCPFree(const iTCPClient: Integer): Boolean;

Availability

SCAR Divi 3.26 > Current

Aliases

  • FreeConnection (SCAR Divi 3.00 > Current)

Description

Closes and frees a TCP connection associated with the index iTCPClient in the TCP client resource manager. Returns false no client was associated with iTCPClient.

Example

var
  i: Integer;
  Nick, s: string;
  Running: Boolean;

begin
  Running := True;
  Nick := 'Test' + IntToStr(Random(999));
  i := TCPConnect('irc.scar-divi.com', 6667, 1000);
  try
    TCPSend(i, 'NICK ' + Nick);
    TCPSend(i, 'USER ' + Nick + ' 0 * :' + Nick);
    TCPSend(i, 'JOIN #scar');
    while Running do
    begin
      TCPReceive(i, s);
      if s = '' then
        Wait(500)
      else
        WriteLn(s);
      if Pos('= #scar', s) > 0 then
      begin
        TCPSend(i, 'PRIVMSG #scar :Hello World!');
        Running := False;
      end;
    end;
  finally
    TCPFree(i);
  end;
end.

See Also