vcmptr

  • Jr. Member
  • This user novice scripter.
  • Posts: 60
HTTP with Sockets
« on August 8th, 2015, 01: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.
My English is not good.

PlayerX

  • Newbie
  • Free Hoster
  • Posts: 29
If some see me on a server and see that I'm not from Argentina, is an impostor >_>.
Playing since 9 years.

ysc3839

  • VC:MP Beta Tester
  • Posts: 621
Re: HTTP with Sockets
« Reply #3, on August 8th, 2015, 07:42 AM »
A very simple HTTP request.
Code: [Select]
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);
}

KAKAN

  • Wiki Contributor
  • Posts: 3,343
You can contact me using Discord, at Developers.CPP( check off-board to find the invite link )
Github: https://github.com/theKAKAN

vcmptr

  • Jr. Member
  • This user novice scripter.
  • Posts: 60
Re: HTTP with Sockets
« Reply #5, on August 8th, 2015, 11:49 AM »
Quote from ysc3839 on August 8th, 2015, 07:42 AM
A very simple HTTP request.
Code: [Select]
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! :)
My English is not good.