AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   sock_read (https://forums.alliedmods.net/showthread.php?t=117694)

ProIcons 02-03-2010 15:45

sock_read
 
Delete plz

Bugsy 02-03-2010 16:22

Re: sock_read
 
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

ProIcons 02-04-2010 02:48

Re: sock_read
 
Quote:

set_task(0.5, "socket_read")



Bugsy 02-04-2010 08:12

Re: sock_read
 
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 );
    }



Exolent[jNr] 02-04-2010 15:26

Re: sock_read
 
Don't remove your question from your topic.
It may help someone else that comes along.

ProIcons 02-06-2010 19:23

Re: sock_read
 
thx


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

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