Discussion list for Unity developers.
unity-dev at moock.org
Tue Feb 13 08:33:18 CST 2007
Hello,
I've tried to send UPC message with a PHP script using the documentation
http://moock.org/unity/metro/docs/general/upc/upcmessageref.html
http://moock.org/unity/metro/docs/general/upc/index.html
I've open a socket connexion (9101) with the unity server using the PHP
function
$unity_ip="udp://XXX.XXX.XXX.XXX";
$unity_port="9101";
$fp = fsockopen ($unity_ip, $unity_port);
No error sent back, the connexion seems to take place
But when a try to read the socket my program read nothing
using :
$res .= fread($fp, 1024);
OR
$res .= fgets($fp, 1024);
Even if I try to read the socket before or after sending a UPC message
Upc message for loggin I send:
<U>
<R>unity</R>
<M>u14</M>
<L>
<A>admin</A><A>XXXXXX</A>
</L>
</U>
I've tried "tcp" but the programme wait a long time before releasing the
connexion with no info on the socket
Something obvious I'm missing (I post the phpscript and the result of
execution)?
Rui
Here is our result of the php execution:
----------------------------------------
Start TEST
Connexion to [udp://XXX.XXX.XXX.179] On Port [9101]
Read the socket
Message to send
<U>
<R>unity</R>
<M>u14</M>
<L>
<A>admin</A><A>XXXXXXX</A>
</L>
</U>
End to send
Sending Message
Characters sent==>[88]<==
Socket read 100 times
Unity Response ==>
End Unity Response
--------------------------------------------
The PHP Script :
<?php
$unity_port=9101;
$unity_ip="udp://XXX.XXX.XXX.179";
echo "Start TEST\r\n";
echo "Connexion to [".$unity_ip."] On Port [".$unity_port."]\r\n";
$fp = fsockopen ($unity_ip, $unity_port);
if(!$fp) {
echo "$errstr ($errno)<br>\n";
}
else
{
//stream_set_blocking ( $fp, TRUE);
$id_room="unity";
$id_message="u14";
$params[0]="admin";
$params[1]="XXXXXX";
//echo "Read the socket\r\n";
//$res .= fgets ($fp, 1024);
//$res .= fread($fp, 1024);
$the_message=unity_message($id_room,$id_message,$params);
echo "Message to send\r\n".$the_message."\r\nEnd to send\r\n";
echo "Sending Message\r\n";
$int_return = fputs ($fp, $the_message);
echo "Characters sent==>[".$int_return."]<==\r\n";
if($int_return)
{
$cpt=0;
sleep (5);
while ($cpt < 100)
{
$res .= fgets ($fp, 1024);
$cpt++;
}
echo "Socket read ".$cpt." times\r\n";
}
echo "Unity Response ==>\r\n".$res."\r\nEnd Unity Response\r\n";
fclose($fp);
}
function unity_message($id_room,$id_message,$params=array())
{
$request_xml="
<U>
<R>".$id_room."</R>
<M>".$id_message."</M>
<L>
";
while (list($header, $value) = each($params))
{
$request_xml.="<A>".$value."</A>";
}
$request_xml.="
</L>
</U>
";
return $request_xml;
}
?>
-----Original Message-----
From: unity-dev-bounces at moock.org [mailto:unity-dev-bounces at moock.org]On
Behalf Of Discussion list for Unity developers.
Sent: vendredi 2 février 2007 19:58
To: unity-dev at moock.org
Subject: Re: ||unity-dev|| testing our server potential AND using PHP
script to make admin requests
1) it sounds like you are hitting a thread limit either on the test
machine or the server machine. try increasing the available threads on
both systems. i'm also checking with Derek to see if there's anything
else that might be causing the 900-client cap.
2) when using unity with languages other than ActionScript, you simply
connect to the server, then communicate using raw UPC messages. a list
of messages and responses is available here:
http://moock.org/unity/metro/docs/general/upc/
colin