Squirrel/Server/Functions/Sockets/Connect

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(New page: __NOTOC__ This function connects the socket to the given server as a client. == Syntax == <code>bool Socket.Connect( string IP, int port )</code> == Arguments == * '''IP''' - This is t...)
 
(Example)
Line 13: Line 13:
 
== Example ==
 
== Example ==
  
{{Squirrel/NeedsExample}}
 
 
<code lang="squirrel">
 
<code lang="squirrel">
-- todo
+
function onScriptLoad( )
 +
{
 +
p_Socket <- NewSocket( "Function" );
 +
p_Socket.Connect( 127.0.0.1, 6667 );
 +
}
 
</code>
 
</code>
 +
 +
On script load this will connect a socket bot to local host via the 6667 port, the socket will run off the "Function" function.
  
 
=== Notes ===
 
=== Notes ===
  
-- Example notes/used functions here
+
The call [[Squirrel/Server/Events/Misc/onScriptLoad|onScriptLoad]] was used in in this example. The function [[Squirrel/Server/Functions/Sockets/NewSocket|NewSocket]] was also used. More info about these in the corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Server/Functions/Sockets}}
 
{{Squirrel/Server/Functions/Sockets}}

Revision as of 03:25, 8 March 2010

This function connects the socket to the given server as a client.

Syntax

  1. bool Socket.Connect( string IP, int port )

Arguments

  • IP - This is the IP address of the remote host
  • port - This is the port of the remote host

Example

  1.  
  2. function onScriptLoad( )
  3. {
  4. p_Socket <- NewSocket( "Function" );
  5. p_Socket.Connect( 127.0.0.1, 6667 );
  6. }
  7.  

On script load this will connect a socket bot to local host via the 6667 port, the socket will run off the "Function" function.

Notes

The call onScriptLoad was used in in this example. The function NewSocket was also used. More info about these in the corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox