Difference between revisions of "TCPConnect"
From SCAR Divi Manual
(Created page with "==Definition== <source lang="scar" lines="false"> function TCPConnect(const Host: AnsiString; const Port, TimeOut: Integer): Integer; </source> ==Availability== SCAR Divi 3.26 >...") |
(No difference)
|
Revision as of 09:45, 4 July 2011
Definition
function TCPConnect(const Host: AnsiString; const Port, TimeOut: Integer): Integer;
Availability
SCAR Divi 3.26 > Current
Aliases
- OpenConnection (SCAR Divi 3.00 > Current)
Description
Opens a new TCP connection to the server given by Host at the port given by Port with a connection timeout given by TimeOut. The function returns the index associated with the connection in the TCP resource manager.
Example
var i: Integer; Nick, s: string; Running: Boolean; begin Running := True; Nick := 'Test' + IntToStr(Random(999999)); i := TCPConnect('irc.scar-divi.com', 6667, 1000); try TCPWrite(i, 'NICK ' + Nick); TCPWrite(i, 'USER ' + Nick + ' 0 * :' + Nick); TCPWrite(i, 'JOIN #scar'); while Running do begin TCPRead(i, s); if s = '' then Wait(500) else WriteLn(s); if Pos('= #scar', s) > 0 then begin TCPWrite(i, 'PRIVMSG #scar :Hello World!'); Running := False; end; end; finally TCPFree(i); end; end.