Scripting/Squirrel/Functions/NewSocket/Example

From Vice City Multiplayer
Revision as of 15:28, 11 March 2016 by Ysc3839 (talk | contribs) (Created page with "== Client == An HTTP request example. <source lang=squirrel>function HTTP() { Socket <- NewSocket( "dataReceived" ); Socket.SetNewConnFunc( "newConn" ); Socket.Connect( "ww...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

Client

An HTTP request example.

function HTTP()
{
	Socket <- NewSocket( "dataReceived" );
	Socket.SetNewConnFunc( "newConn" );
	Socket.Connect( "www.example.com", 80 )
}

function dataReceived( data )
{
	print( data );
}

function newConn()
{
	local request = @"GET / HTTP/1.0
Host: www.example.com

";
	Socket.Send( request );
}

Server