Squirrel/Server/Functions/Sockets/Connect
From Liberty Unleashed Wiki
(Difference between revisions)
(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 == | ||
− | |||
<code lang="squirrel"> | <code lang="squirrel"> | ||
− | - | + | 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 === | ||
− | + | 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
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
function onScriptLoad( ) { p_Socket <- NewSocket( "Function" ); p_Socket.Connect( 127.0.0.1, 6667 ); }
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.