Raised This Month: $ Target: $400
 0% 

sock_read


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-04-2010 , 08:12   Re: sock_read
Reply With Quote #4

Try this

PHP Code:
#include <amxmodx>
#include <sockets>

#define TASK_RECV    551122
new Float:g_fResponseTime33 ];

public 
plugin_init() 
{
    
register_plugin"sockets" "0.1" "bugsy" );
    
register_concmd"test" "TestConnect" );
}

public 
TestConnectid )
{    
    new 
iSocket iError;
    
    
g_fResponseTimeid ] = get_gametime();
    
iSocket socket_open"www.google.com" 80 SOCKET_TCP iError );
    
    if ( !
iSocket || iError )
        return 
PLUGIN_HANDLED;
        
    new 
szPacket[] = "GET / HTTP/1.1^r^nHost: www.google.com^r^n^r^n";
    
socket_sendiSocket szPacket sizeofszPacket ) );
    
    new 
params];
    
params] = id;
    
params] = iSocket;
    
set_task0.25 "ReadData" TASK_RECV params sizeofparams ) , "b" );

    return 
PLUGIN_HANDLED;
}

public 
ReadDataparams] )
{
    new 
id params];
    new 
iSocket params];
    static 
szData512 ];
    
    if ( 
socket_changeiSocket ) )
    {
        
socket_recviSocket szData charsmaxszData ) );
        
g_fResponseTimeid ] = get_gametime();
        
        
server_printszData );
        
//check for your data, if found call remove_task( TASK_RECV );
    
}
    
    if ( ( 
get_gametime() - g_fResponseTimeid ] ) >= 5.0 )
    {
        
//server hasn't responded in 5 seconds
        
remove_taskTASK_RECV );
    }

__________________

Last edited by Bugsy; 02-04-2010 at 08:52.
Bugsy is offline
 



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 07:23.


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