Raised This Month: $ Target: $400
 0% 

sock_read


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 02-03-2010 , 15:45   sock_read
Reply With Quote #1

Delete plz
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))

Last edited by ProIcons; 02-04-2010 at 09:39.
ProIcons is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-03-2010 , 16:22   Re: sock_read
Reply With Quote #2

you should check if the socket successfully opened prior to sending data. you are not recving data because you are reading data immediately after sending your packet. you need to give the server time to respond. see my VAC ban status plugin. link in my sig

you can solve this issue by using a repeating set_task to check for data at an interval
__________________

Last edited by Bugsy; 02-03-2010 at 16:24.
Bugsy is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 02-04-2010 , 02:48   Re: sock_read
Reply With Quote #3

Quote:
set_task(0.5, "socket_read")


__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
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
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-04-2010 , 15:26   Re: sock_read
Reply With Quote #5

Don't remove your question from your topic.
It may help someone else that comes along.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 02-06-2010 , 19:23   Re: sock_read
Reply With Quote #6

thx
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
Reply



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