It's possible that server_print() will only show up to X characters per print, but I'm not sure on that one.
There are some instances where you will not receive all data in a single socket_recv() call. I quickly put this together to show you how to get an entire file. It will write all received data to TESTFILE.txt in your mod directory.
PHP Code:
#include <amxmodx>
#include <sockets>
new g_Socket;
const TASKID = 5213;
public plugin_init()
{
register_concmd( "test" , "test" );
}
public test()
{
new sendbuffer[512] , error
g_Socket = socket_open( "www.google.com" , 80 , SOCKET_TCP , error );
if ( g_Socket && !error )
{
formatex( sendbuffer , charsmax( sendbuffer ) , "GET /index.html HTTP/1.1^nHost: www.google.com^n^n" );
socket_send( g_Socket, sendbuffer , sizeof( sendbuffer ) );
//Create a task to check for data every second (you would want a faster interval in real-world situations)
set_task( 1.0 , "CheckForData" , TASKID , .flags="b" );
//Create a task to close the socket and stop checking for data after 60 seconds. There are cleaner ways, this
//was just a fast method for demonstration.
set_task( 60.0 , "CloseSocket" );
}
}
public CheckForData()
{
static g_Data[2000];
new iRecv;
server_print("Checking for data")
if ( socket_change( g_Socket ) )
{
iRecv = socket_recv(g_Socket, g_Data, charsmax( g_Data ) )
server_print("Recv=%d Data: %s", iRecv , g_Data)
write_file( "TESTFILE.txt" , g_Data );
}
}
public CloseSocket()
{
socket_close( g_Socket );
remove_task( TASKID );
}
__________________