Code:
#include <amxmodx>
#include <amxmisc>
#include <sockets>
#define HOST "192.168.1.133"
#define FILE "/amxx.php"
//http://ozforce.my-place.us/amxx.php
#define SCRIPT_NAME "/myplugin/parser.php"
#define REMOTE_HOST "myserver.com" //port d.80
new g_TimeSocket
new g_GetSocket
public plugin_init()
register_clcmd("say !sock","CmdSock");
public CmdSock(id)
{
new Error
g_TimeSocket = socket_open("www.worldtimeserver.com",80,SOCKET_TCP,Error);
if(Error != 0)
{
client_print(id,print_chat,"[TEST] Unable to Open Socket.");
return PLUGIN_HANDLED
}
client_print(id,print_chat,"[TEST] Socket Opened.");
set_task(1.5,"SockSend");
return PLUGIN_HANDLED
}
public SockSend()
{
new Buffer[128]
format(Buffer,127,"GET %s HTTP/1.1^nHost: %s^n^n","current_time_in_MV.aspx","www.worldtimeserver.com");
socket_send(g_TimeSocket,Buffer,127);
set_task(1.5,"SockGetData");
client_print(0,print_chat,"[TEST] Socket Sent.");
}
public SockGetData()
{
new Buffer[1024]
if(!socket_change(g_TimeSocket,100))
{
client_print(0,print_chat,"[TEST] No Data");
return set_task(1.0,"SockGetData");
}
socket_recv(g_TimeSocket,Buffer,1023);
socket_close(g_TimeSocket);
client_print(0,print_console,"[TEST] I got: %s",Buffer);
client_print(0,print_chat,"[TEST] Socket Recieved.");
return 1
}
And I get a "400 Bad Request" Error. So I know everything is working. But how exactly do I work with this? I know that "http://www.worldtimeserver.com/current_time_in_MV.aspx" returns the time. I figured it would return the HTML Source of the page. Any ideas how I can get the data (time) from "http://www.worldtimeserver.com/current_time_in_MV.aspx"?