Raised This Month: $ Target: $400
 0% 

Sockets (Getting Time)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 04-04-2009 , 20:32   Sockets (Getting Time)
Reply With Quote #1

I have:
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"?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode