Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: vcmptr on Aug 08, 2015, 12:43 AM

Title: HTTP with Sockets
Post by: vcmptr on Aug 08, 2015, 12:43 AM
Can I get HTTP page content using sockets? I don't know how to use socket but if it's possible I will try learn use sockets.
Title: Re: HTTP with Sockets
Post by: PlayerX on Aug 08, 2015, 01:31 AM
Yes...

http://wiki.vc-mp.org/wiki/Query_Mechanism

example:

$res = new VCMPQuery("31.220.22.42", 8192);
$info = $res->getServerInfo();
echo $info['hostname'];
Title: Re: HTTP with Sockets
Post by: ysc3839 on Aug 08, 2015, 05:43 AM
Quote from: PlayerX on Aug 08, 2015, 01:31 AMYes...

http://wiki.vc-mp.org/wiki/Query_Mechanism

example:

$res = new VCMPQuery("31.220.22.42", 8192);
$info = $res->getServerInfo();
echo $info['hostname'];

He means use the socket plugin to get a html page.
Title: Re: HTTP with Sockets
Post by: ysc3839 on Aug 08, 2015, 06:42 AM
A very simple HTTP request.
function HTTP()
{
Socket <- NewSocket("DataFunc");
Socket.SetNewConnFunc("ConnFunc");
Socket.Connect("www.example.com", 80)
}

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

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

";
Socket.Send(request);
}
Title: Re: HTTP with Sockets
Post by: KAKAN on Aug 08, 2015, 09:24 AM
Hmm, it'll help me too!
Title: Re: HTTP with Sockets
Post by: vcmptr on Aug 08, 2015, 10:49 AM
Quote from: ysc3839 on Aug 08, 2015, 06:42 AMA very simple HTTP request.
function HTTP()
{
Socket <- NewSocket("DataFunc");
Socket.SetNewConnFunc("ConnFunc");
Socket.Connect("www.example.com", 80)
}

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

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

";
Socket.Send(request);
}
Thanks ysc! :)