getting some zone info using php

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
dream
Posts: 21
Joined: 21 Aug 2006, 13:54
Location: Bucharest, Romania
Contact:

getting some zone info using php

Post by dream »

hello Lapo,
I used a simple php script to connect to the sfs. I create the socket, then connect to the server, then I send some data.. but I don't get the response

here is the small script.. I used bold on the areas that might present a problem.

<?
$ip = '216.xxx.xxx.xx';
$port = 'xxxx';

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) echo "socket_create() failed: reason: " , socket_strerror($socket) , "\n";
else echo "OK.\n";

$result = socket_connect($socket, $ip, $port);
if ($result < 0) echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
else echo "OK.\n";

$in = "<msg t='sys'><body action='verChk' r='0'><ver v='102' /></body></msg>";
$out = '';

socket_write($socket, $in, strlen($in));

while ($out = socket_read($socket, 2048)) {
echo $out;
}

socket_close($socket);
?>
Last edited by dream on 08 Nov 2006, 10:47, edited 2 times in total.
nature has a funny way of breaking what does not bend
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

All messages from client to server and vice versa follow the Flash XMLSocket() object format, which puts a 0x00 byte at the end of the string.

Just add a byte 0 to the end of your messages and it should work
Lapo
--
gotoAndPlay()
...addicted to flash games
dream
Posts: 21
Joined: 21 Aug 2006, 13:54
Location: Bucharest, Romania
Contact:

Post by dream »

i can't seem to get it to work.. I tried both the "\0" char and "\x00" in php..
do you have an article on general php clients trying to emulate the flash xml send function? I have searched but did not find anything valuable...

I connected also via telnet just for fun but was not able to send a message because I don;t know how to send the 0x00 character in the end
nature has a funny way of breaking what does not bend
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

do you have an article on general php clients trying to emulate the flash xml send function?
No, we don't have articles about PHP connectin' to SFS.
However PHP has a rich set of functions, I'd recommend to check the online documentation (www.php.net) or download the manual and look for examples under the "Socket" section or the "String" section.

You probably need a String function that adds a 0x00 byte to the end of your string or to the socket byte stream.
Lapo
--
gotoAndPlay()
...addicted to flash games
dream
Posts: 21
Joined: 21 Aug 2006, 13:54
Location: Bucharest, Romania
Contact:

Post by dream »

has anyone done this successfuly? if so, please tell me.. post it here.. any php code that connects to the server and exchanges info would be greatly appreciated. Thank you.
nature has a funny way of breaking what does not bend
Post Reply