Page 1 of 1

how to communication with the Access Controller?

Posted: Tue Aug 16, 2005 12:05 am
by samuelxin
Hi every one
i have a Access Controller mechine
want send data and get the data from server

the retailer say i can use the TCP/IP to communication with it
i try meny time, use the socket, but fail.
could you teach me how to
thank you

code

Code: Select all

$ip='280.88.287.18';  // i used also udp, but fail  udp://280.88.287.18 
$port=4660;             //port 
$packet = '078000052'; // send the data, ascii code 
 $fp = fsockopen($ip, $port, $errno, $errstr, 30); // 

fwrite($fp, $packet); //send data 

while (!feof($fp)) { 
    $data=fread($fp, 26);  // read 
    echo $data; 
}

Posted: Tue Aug 16, 2005 5:26 am
by timvw
Might want to add a newline to your command:

Code: Select all

$ip='280.88.287.18';
$port=4660;
$packet = '078000052' . "\n";
  
$fp = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$fp) 
{
   echo "$errstr ($errno) <br/>";
}
else
{
  fwrite($fp, $packet);

  while (!feof($fp)) 
  {
    $data=fgets($fp, 128);
    echo $data;
  }
}