1. Default HTTP port is 80 (unless the site is configured otherwise)
2. You have the HTTP request formatted incorrectly.
3. You should send the entire HTTP request in 1 packet
4. You are trying to receive data immediately after sending it. No web server will respond that fast.
Untested
PHP Code:
new g_Socket;
public SendRequest()
{
new iError;
g_Socket = socket_open( "127.0.0.1" , 80 , SOCKET_TCP , iError );
if( g_Socket && !iError )
{
static szPacket[256];
formatex( szPacket , 255 , "GET /index.php HTTP/1.1^r^nHost: 127.0.0.1^r^nConnection: close^r^n^r^n" );
socket_send( g_Socket , szPacket , strlen(szPacket) );
if( !task_exists( 5511 ) )
set_task( 0.25 , "RecvData" , 5511 , _, _, "b" );
}
}
public RecvData()
{
static szData[1024];
if ( socket_change( g_Socket ) )
{
socket_recv( g_Socket , szData , 1023 );
if ( strlen( szData ) )
{
server_print( szData );
szData[0] = 0;
/*if ( containi( szData , "make it stop" ) > -1 )
{
remove_task( 5511 );
socket_close( g_Socket );
}*/
}
}
}
__________________