0

Hello i am trying to make a simple game but i need server, so i started learning for sockets on flash but when i send session to the php page with get parameter its like the page don't have get parameters and like i am just entering just the normal page (Example: index.php?something=something2 and it connects to index.php without the something)

Here is what i mean:

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

The portocol i send:

mysocket.writeUTF(" GET /index.php?act=getip HTTP/1.1\r\n Host: 192.168.1.100\r\n\r\n");

My php page:

<?
include 'all.php';//mysql connect, escaping all get/post params
if($_GET["act"] == 'getip'){
die($_SERVER["REMOTE_ADDR"]);//this must be printed on the screen
}
print 'asd';//<-------------------- i get this on connecting
?>

1 Answer 1

1

If you want to have an HTTP based communication, just use flash.net.URLLoader.

var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("http://192.168.1.100/index.php?act=ip");

function completeHandler(event:Event):void
{
    var ip:String = loader.data;
}

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html

Sign up to request clarification or add additional context in comments.

1 Comment

What do you mean the page source code ? If you want to retrieve the response of the server, user loader.data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.